From: Timo Sirainen Date: Thu, 22 Jun 2017 06:05:06 +0000 (+0300) Subject: lib: Add file_lock_set_path() X-Git-Tag: 2.3.0.rc1~1367 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8d93ecd89efa7c84a3a21264a550449619f715b;p=thirdparty%2Fdovecot%2Fcore.git lib: Add file_lock_set_path() --- diff --git a/src/lib/file-lock.c b/src/lib/file-lock.c index 4881e284a1..2b686dcab6 100644 --- a/src/lib/file-lock.c +++ b/src/lib/file-lock.c @@ -372,6 +372,14 @@ const char *file_lock_get_path(struct file_lock *lock) return lock->path; } +void file_lock_set_path(struct file_lock *lock, const char *path) +{ + if (path != lock->path) { + i_free(lock->path); + lock->path = i_strdup(path); + } +} + void file_lock_wait_start(void) { i_assert(lock_wait_start.tv_sec == 0); diff --git a/src/lib/file-lock.h b/src/lib/file-lock.h index c0d62211cf..2d36222953 100644 --- a/src/lib/file-lock.h +++ b/src/lib/file-lock.h @@ -53,6 +53,9 @@ void file_lock_free(struct file_lock **lock); /* Returns the path given as parameter to file_*lock*(). */ const char *file_lock_get_path(struct file_lock *lock); +/* Update lock file's path (after it gets renamed by the caller). This is + useful mainly together with file_lock_set_unlink_on_free(). */ +void file_lock_set_path(struct file_lock *lock, const char *path); /* Returns human-readable string containing the process that has the file currently locked. Returns "" if unknown, otherwise " (string)". */