]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 3 Jul 2017 12:13:24 +0000 (15:13 +0300)
src/lib/file-lock.c
src/lib/file-lock.h

index 32404f4204e36b175d02f2999dc08bcca9f67ff3..e96d06b0dd11e33102d032b554d926db7becb0b6 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)". */