changeset 22266:d165150e8883

lib: Add file_lock_get_path() This allows getting the file path from the lock without having to preserve it separately.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 22 Jun 2017 01:42:56 +0300
parents 66e02e3235d3
children ce98be82d4d6
files src/lib/file-lock.c src/lib/file-lock.h
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/file-lock.c	Wed Jun 28 15:50:11 2017 +0300
+++ b/src/lib/file-lock.c	Thu Jun 22 01:42:56 2017 +0300
@@ -367,6 +367,11 @@
 	i_free(lock);
 }
 
+const char *file_lock_get_path(struct file_lock *lock)
+{
+	return lock->path;
+}
+
 void file_lock_wait_start(void)
 {
 	i_assert(lock_wait_start.tv_sec == 0);
--- a/src/lib/file-lock.h	Wed Jun 28 15:50:11 2017 +0300
+++ b/src/lib/file-lock.h	Thu Jun 22 01:42:56 2017 +0300
@@ -51,6 +51,9 @@
 /* Free the lock without unlocking it (because you're closing the fd anyway). */
 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);
+
 /* Returns human-readable string containing the process that has the file
    currently locked. Returns "" if unknown, otherwise " (string)". */
 const char *file_lock_find(int lock_fd, enum file_lock_method lock_method,