diff --git a/src/common/lock.c b/src/common/lock.c index 8d5c45e17..ae2efd3ee 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -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); diff --git a/src/common/lock.h b/src/common/lock.h index 307f4ad10..0547b9c24 100644 --- a/src/common/lock.h +++ b/src/common/lock.h @@ -18,6 +18,11 @@ typedef enum #include "common/type/string.h" #include "common/time.h" +/*********************************************************************************************************************************** +Constants +***********************************************************************************************************************************/ +#define LOCK_FILE_EXT ".lock" + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/test/src/module/command/remoteTest.c b/test/src/module/command/remoteTest.c index 3c7c27022..0dbf8ef67 100644 --- a/test/src/module/command/remoteTest.c +++ b/test/src/module/command/remoteTest.c @@ -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); } diff --git a/test/src/module/common/lockTest.c b/test/src/module/common/lockTest.c index 11e2c5be2..d13bff334 100644 --- a/test/src/module/common/lockTest.c +++ b/test/src/module/common/lockTest.c @@ -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; // -------------------------------------------------------------------------------------------------------------------------