mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Add constant for lock file extension.
Contributed by Cynthia Shang.
This commit is contained in:
parent
efc62c9057
commit
feec674b6f
@ -189,7 +189,7 @@ lockAcquire(const String *lockPath, const String *stanza, LockType lockType, Tim
|
||||
|
||||
for (LockType lockIdx = lockMin; lockIdx <= lockMax; lockIdx++)
|
||||
{
|
||||
lockFile[lockIdx] = strNewFmt("%s/%s-%s.lock", strPtr(lockPath), strPtr(stanza), lockTypeName[lockIdx]);
|
||||
lockFile[lockIdx] = strNewFmt("%s/%s-%s" LOCK_FILE_EXT, strPtr(lockPath), strPtr(stanza), lockTypeName[lockIdx]);
|
||||
|
||||
lockHandle[lockIdx] = lockAcquireFile(lockFile[lockIdx], lockTimeout, failOnNoLock);
|
||||
|
||||
|
@ -18,6 +18,11 @@ typedef enum
|
||||
#include "common/type/string.h"
|
||||
#include "common/time.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constants
|
||||
***********************************************************************************************************************************/
|
||||
#define LOCK_FILE_EXT ".lock"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -160,7 +160,7 @@ testRun(void)
|
||||
TEST_ASSIGN(client, protocolClientNew(strNew("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), "create client");
|
||||
protocolClientNoOp(client);
|
||||
|
||||
storageExistsNP(storageTest, strNewFmt("--lock-path=%s/lock/test-archive.lock", testPath()));
|
||||
storageExistsNP(storageTest, strNewFmt("--lock-path=%s/lock/test-archive" LOCK_FILE_EXT, testPath()));
|
||||
|
||||
protocolClientFree(client);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ testRun(void)
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("lockAcquireFile() and lockReleaseFile()"))
|
||||
{
|
||||
String *archiveLock = strNewFmt("%s/main-archive.lock", testPath());
|
||||
String *archiveLock = strNewFmt("%s/main-archive" LOCK_FILE_EXT, testPath());
|
||||
int lockHandleTest = -1;
|
||||
|
||||
TEST_RESULT_INT(system(strPtr(strNewFmt("touch %s", strPtr(archiveLock)))), 0, "touch lock file");
|
||||
@ -48,7 +48,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(lockReleaseFile(lockHandleTest, archiveLock), "release lock again without error");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
String *subPathLock = strNewFmt("%s/sub1/sub2/db-backup.lock", testPath());
|
||||
String *subPathLock = strNewFmt("%s/sub1/sub2/db-backup" LOCK_FILE_EXT, testPath());
|
||||
|
||||
TEST_ASSIGN(lockHandleTest, lockAcquireFile(subPathLock, 0, true), "get lock in subpath");
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, subPathLock), true, "lock file was created");
|
||||
@ -57,7 +57,7 @@ testRun(void)
|
||||
TEST_RESULT_BOOL(storageExistsNP(storageTest, subPathLock), false, "lock file was removed");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
String *dirLock = strNewFmt("%s/dir.lock", testPath());
|
||||
String *dirLock = strNewFmt("%s/dir" LOCK_FILE_EXT, testPath());
|
||||
|
||||
TEST_RESULT_INT(system(strPtr(strNewFmt("sudo mkdir -p 750 %s", strPtr(dirLock)))), 0, "create dirtest.lock dir");
|
||||
|
||||
@ -78,7 +78,7 @@ testRun(void)
|
||||
strPtr(noPermLock), strPtr(noPermLock))));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
String *backupLock = strNewFmt("%s/main-backup.lock", testPath());
|
||||
String *backupLock = strNewFmt("%s/main-backup" LOCK_FILE_EXT, testPath());
|
||||
|
||||
HARNESS_FORK_BEGIN()
|
||||
{
|
||||
@ -110,8 +110,8 @@ testRun(void)
|
||||
{
|
||||
String *stanza = strNew("test");
|
||||
String *lockPath = strNew(testPath());
|
||||
String *archiveLockFile = strNewFmt("%s/%s-archive.lock", testPath(), strPtr(stanza));
|
||||
String *backupLockFile = strNewFmt("%s/%s-backup.lock", testPath(), strPtr(stanza));
|
||||
String *archiveLockFile = strNewFmt("%s/%s-archive" LOCK_FILE_EXT, testPath(), strPtr(stanza));
|
||||
String *backupLockFile = strNewFmt("%s/%s-backup" LOCK_FILE_EXT, testPath(), strPtr(stanza));
|
||||
int lockHandleTest = -1;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user