]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add file_lock_set_path()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 22 Jun 2017 06:05:06 +0000 (09:05 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 28 Jun 2017 18:59:03 +0000 (21:59 +0300)
src/lib/file-lock.c
src/lib/file-lock.h

index 4881e284a17a24d41de9ec14b977c5a210cbd469..2b686dcab6fe3aa8c04ee51761b67f07e33604e7 100644 (file)
@@ -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);
index c0d62211cf2284014228e03e5637ce04f7c83822..2d36222953f7329e78167d911212fb42fa02cee7 100644 (file)
@@ -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)". */