1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-06 03:53:59 +02:00
pgbackrest/libc/xs/common/lock.xs

45 lines
1.4 KiB
Plaintext
Raw Normal View History

# ----------------------------------------------------------------------------------------------------------------------------------
# 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