1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00
pgbackrest/libc/xs/common/lock.xs
David Steele edb2c6eb26 Construct Wait object in milliseconds instead of fractional seconds.
The Wait object accepted a double in the constructor for wait time but used TimeMSec internally.  This was done for compatibility with the Perl code.

Instead, use TimeMSec in the Wait constructor and make changes as needed to calling code.

Note that Perl still uses a double for its Wait object so translation is needed in some places.  There are no plans to update the Perl code as it will become obsolete.
2018-11-08 08:37:57 -05:00

45 lines
1.4 KiB
Plaintext

# ----------------------------------------------------------------------------------------------------------------------------------
# Lock Exports
# ----------------------------------------------------------------------------------------------------------------------------------
MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
####################################################################################################################################
bool
lockAcquire(lockPath, command, stanza, lockTimeout, failOnNoLock)
const char *lockPath
const char *command
const char *stanza
double lockTimeout
bool failOnNoLock
CODE:
RETVAL = false;
MEM_CONTEXT_XS_TEMP_BEGIN()
{
// Set the command so we can get the correct lock type to use
cfgCommandSet(cfgCommandId(command));
// Attempt to acquire the lock
if (cfgLockRequired())
RETVAL = lockAcquire(strNew(lockPath), strNew(stanza), cfgLockType(), (TimeMSec)(lockTimeout * 1000), failOnNoLock);
}
MEM_CONTEXT_XS_TEMP_END();
OUTPUT:
RETVAL
####################################################################################################################################
bool
lockRelease(failOnNoLock)
bool failOnNoLock
CODE:
RETVAL = false;
MEM_CONTEXT_XS_TEMP_BEGIN()
{
RETVAL = lockRelease(failOnNoLock);
}
MEM_CONTEXT_XS_TEMP_END();
OUTPUT:
RETVAL