From: Stephan Bosch Date: Mon, 20 Sep 2021 00:39:08 +0000 (+0200) Subject: lib: file-lock - Rename file_{wait,try}_lock_error() to file_{wait,try}_lock(). X-Git-Tag: 2.3.17~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de5e12a160604842ff2f0348c7f0627055b74c53;p=thirdparty%2Fdovecot%2Fcore.git lib: file-lock - Rename file_{wait,try}_lock_error() to file_{wait,try}_lock(). --- diff --git a/src/lib-dict/dict-file.c b/src/lib-dict/dict-file.c index eef096e0f8..54ff92b745 100644 --- a/src/lib-dict/dict-file.c +++ b/src/lib-dict/dict-file.c @@ -522,10 +522,10 @@ file_dict_lock(struct file_dict *dict, struct file_lock **lock_r, *lock_r = NULL; do { file_lock_free(lock_r); - if (file_wait_lock_error(dict->fd, dict->path, F_WRLCK, - dict->lock_method, - file_dict_dotlock_settings.timeout, - lock_r, &error) <= 0) { + if (file_wait_lock(dict->fd, dict->path, F_WRLCK, + dict->lock_method, + file_dict_dotlock_settings.timeout, + lock_r, &error) <= 0) { *error_r = t_strdup_printf( "file_wait_lock(%s) failed: %s", dict->path, error); diff --git a/src/lib-fs/fs-posix.c b/src/lib-fs/fs-posix.c index 9e9d3e4a8e..66859b8880 100644 --- a/src/lib-fs/fs-posix.c +++ b/src/lib-fs/fs-posix.c @@ -702,15 +702,13 @@ fs_posix_lock(struct fs_file *_file, unsigned int secs, struct fs_lock **lock_r) file->full_path); #else if (secs == 0) { - ret = file_try_lock_error(file->fd, file->full_path, - F_WRLCK, - FILE_LOCK_METHOD_FLOCK, - &fs_lock.file_lock, &error); + ret = file_try_lock(file->fd, file->full_path, F_WRLCK, + FILE_LOCK_METHOD_FLOCK, + &fs_lock.file_lock, &error); } else { - ret = file_wait_lock_error(file->fd, file->full_path, - F_WRLCK, - FILE_LOCK_METHOD_FLOCK, secs, - &fs_lock.file_lock, &error); + ret = file_wait_lock(file->fd, file->full_path, F_WRLCK, + FILE_LOCK_METHOD_FLOCK, secs, + &fs_lock.file_lock, &error); } if (ret < 0) { fs_set_error_errno(_file->event, "flock(%s) failed: %s", diff --git a/src/lib-index/mail-index-lock.c b/src/lib-index/mail-index-lock.c index e14461b5e8..83e106ec90 100644 --- a/src/lib-index/mail-index-lock.c +++ b/src/lib-index/mail-index-lock.c @@ -35,8 +35,8 @@ int mail_index_lock_fd(struct mail_index *index, const char *path, int fd, return 1; } - ret = file_wait_lock_error(fd, path, lock_type, index->set.lock_method, - timeout_secs, lock_r, &error); + ret = file_wait_lock(fd, path, lock_type, index->set.lock_method, + timeout_secs, lock_r, &error); if (ret < 0) e_error(index->event, "%s", error); return ret; diff --git a/src/lib-index/mail-index-strmap.c b/src/lib-index/mail-index-strmap.c index ddfbc547a5..c377508b92 100644 --- a/src/lib-index/mail-index-strmap.c +++ b/src/lib-index/mail-index-strmap.c @@ -1049,10 +1049,10 @@ static int mail_index_strmap_lock(struct mail_index_strmap *strmap) timeout_secs = I_MIN(MAIL_INDEX_STRMAP_TIMEOUT_SECS, strmap->index->set.max_lock_timeout_secs); - ret = file_wait_lock_error(strmap->fd, strmap->path, F_WRLCK, - strmap->index->set.lock_method, - timeout_secs, &strmap->file_lock, - &error); + ret = file_wait_lock(strmap->fd, strmap->path, F_WRLCK, + strmap->index->set.lock_method, + timeout_secs, &strmap->file_lock, + &error); if (ret <= 0) { mail_index_set_error(strmap->index, "file_wait_lock() failed with strmap index file %s: %s", diff --git a/src/lib-storage/index/dbox-common/dbox-file.c b/src/lib-storage/index/dbox-common/dbox-file.c index dd4a2dbf6c..fca8f44023 100644 --- a/src/lib-storage/index/dbox-common/dbox-file.c +++ b/src/lib-storage/index/dbox-common/dbox-file.c @@ -313,8 +313,8 @@ int dbox_file_try_lock(struct dbox_file *file) i_assert(file->fd != -1); #ifdef DBOX_FILE_LOCK_METHOD_FLOCK - ret = file_try_lock_error(file->fd, file->cur_path, F_WRLCK, - FILE_LOCK_METHOD_FLOCK, &file->lock, &error); + ret = file_try_lock(file->fd, file->cur_path, F_WRLCK, + FILE_LOCK_METHOD_FLOCK, &file->lock, &error); if (ret < 0) { mail_storage_set_critical(&file->storage->storage, "file_try_lock(%s) failed: %s", file->cur_path, error); diff --git a/src/lib/file-create-locked.c b/src/lib/file-create-locked.c index 2d68b690ae..38c9137713 100644 --- a/src/lib/file-create-locked.c +++ b/src/lib/file-create-locked.c @@ -29,8 +29,8 @@ try_lock_existing(int fd, const char *path, *error_r = t_strdup_printf("fstat(%s) failed: %m", path); return -1; } - if (file_wait_lock_error(fd, path, F_WRLCK, set->lock_method, - set->lock_timeout_secs, lock_r, error_r) <= 0) + if (file_wait_lock(fd, path, F_WRLCK, set->lock_method, + set->lock_timeout_secs, lock_r, error_r) <= 0) return -1; if (stat(path, &st2) == 0) { ret = st1.st_ino == st2.st_ino && @@ -104,8 +104,8 @@ try_create_new(const char *path, const struct file_create_settings *set, } ret = -1; - if (file_try_lock_error(fd, str_c(temp_path), F_WRLCK, - set->lock_method, lock_r, error_r) <= 0) { + if (file_try_lock(fd, str_c(temp_path), F_WRLCK, set->lock_method, + lock_r, error_r) <= 0) { } else if (link(str_c(temp_path), path) < 0) { if (errno == EEXIST) { /* just created by somebody else */ diff --git a/src/lib/file-lock.c b/src/lib/file-lock.c index d35d7fdfca..5cfe00a2bc 100644 --- a/src/lib/file-lock.c +++ b/src/lib/file-lock.c @@ -56,12 +56,12 @@ const char *file_lock_method_to_str(enum file_lock_method method) i_unreached(); } -int file_try_lock_error(int fd, const char *path, int lock_type, - enum file_lock_method lock_method, - struct file_lock **lock_r, const char **error_r) +int file_try_lock(int fd, const char *path, int lock_type, + enum file_lock_method lock_method, + struct file_lock **lock_r, const char **error_r) { - return file_wait_lock_error(fd, path, lock_type, lock_method, 0, - lock_r, error_r); + return file_wait_lock(fd, path, lock_type, lock_method, 0, + lock_r, error_r); } static const char * @@ -285,10 +285,9 @@ static int file_lock_do(int fd, const char *path, int lock_type, return 1; } -int file_wait_lock_error(int fd, const char *path, int lock_type, - enum file_lock_method lock_method, - unsigned int timeout_secs, - struct file_lock **lock_r, const char **error_r) +int file_wait_lock(int fd, const char *path, int lock_type, + enum file_lock_method lock_method, unsigned int timeout_secs, + struct file_lock **lock_r, const char **error_r) { struct file_lock *lock; int ret; @@ -382,8 +381,8 @@ static void file_try_unlink_locked(struct file_lock *lock) int ret; file_unlock_real(lock); - ret = file_try_lock_error(lock->fd, lock->path, F_WRLCK, - lock->lock_method, &temp_lock, &error); + ret = file_try_lock(lock->fd, lock->path, F_WRLCK, lock->lock_method, + &temp_lock, &error); if (ret < 0) { i_error("file_lock_free(): Unexpectedly failed to retry locking %s: %s", lock->path, error); diff --git a/src/lib/file-lock.h b/src/lib/file-lock.h index 77e0dd9550..4769c0ed71 100644 --- a/src/lib/file-lock.h +++ b/src/lib/file-lock.h @@ -23,15 +23,14 @@ const char *file_lock_method_to_str(enum file_lock_method method); /* Lock the file. Returns 1 if successful, 0 if file is already locked, or -1 if error. lock_type is F_WRLCK or F_RDLCK. */ -int file_try_lock_error(int fd, const char *path, int lock_type, - enum file_lock_method lock_method, - struct file_lock **lock_r, const char **error_r); +int file_try_lock(int fd, const char *path, int lock_type, + enum file_lock_method lock_method, + struct file_lock **lock_r, const char **error_r); /* Like lock_try_lock(), but return 0 only after having tried to lock for timeout_secs. */ -int file_wait_lock_error(int fd, const char *path, int lock_type, - enum file_lock_method lock_method, - unsigned int timeout_secs, - struct file_lock **lock_r, const char **error_r); +int file_wait_lock(int fd, const char *path, int lock_type, + enum file_lock_method lock_method, unsigned int timeout_secs, + struct file_lock **lock_r, const char **error_r); /* Change the lock type. WARNING: This isn't an atomic operation! The result is the same as file_unlock() + file_try_lock(). */ int file_lock_try_update(struct file_lock *lock, int lock_type); diff --git a/src/plugins/fts-squat/squat-trie.c b/src/plugins/fts-squat/squat-trie.c index 10c83f19c9..d18b004951 100644 --- a/src/plugins/fts-squat/squat-trie.c +++ b/src/plugins/fts-squat/squat-trie.c @@ -292,10 +292,10 @@ static int squat_trie_lock(struct squat_trie *trie, int lock_type, for (;;) { if (trie->lock_method != FILE_LOCK_METHOD_DOTLOCK) { - ret = file_wait_lock_error(trie->fd, trie->path, - lock_type, trie->lock_method, - SQUAT_TRIE_LOCK_TIMEOUT, - file_lock_r, &error); + ret = file_wait_lock(trie->fd, trie->path, + lock_type, trie->lock_method, + SQUAT_TRIE_LOCK_TIMEOUT, + file_lock_r, &error); if (ret < 0) { i_error("squat trie %s: %s", trie->path, error); @@ -1629,10 +1629,10 @@ static int squat_trie_write(struct squat_trie_build_context *ctx) return -1; if (trie->lock_method != FILE_LOCK_METHOD_DOTLOCK) { - ret = file_wait_lock_error(fd, path, F_WRLCK, - trie->lock_method, - SQUAT_TRIE_LOCK_TIMEOUT, - &file_lock, &error); + ret = file_wait_lock(fd, path, F_WRLCK, + trie->lock_method, + SQUAT_TRIE_LOCK_TIMEOUT, + &file_lock, &error); if (ret <= 0) { i_error("file_wait_lock(%s) failed: %s", path, error); diff --git a/src/plugins/fts-squat/squat-uidlist.c b/src/plugins/fts-squat/squat-uidlist.c index 7364431f5a..caf9854acc 100644 --- a/src/plugins/fts-squat/squat-uidlist.c +++ b/src/plugins/fts-squat/squat-uidlist.c @@ -609,11 +609,11 @@ static int squat_uidlist_lock(struct squat_uidlist *uidlist) i_assert(uidlist->dotlock == NULL); if (uidlist->trie->lock_method != FILE_LOCK_METHOD_DOTLOCK) { - ret = file_wait_lock_error(uidlist->fd, uidlist->path, - F_WRLCK, - uidlist->trie->lock_method, - SQUAT_TRIE_LOCK_TIMEOUT, - &uidlist->file_lock, &error); + ret = file_wait_lock(uidlist->fd, uidlist->path, + F_WRLCK, + uidlist->trie->lock_method, + SQUAT_TRIE_LOCK_TIMEOUT, + &uidlist->file_lock, &error); if (ret < 0) { i_error("squat uidlist %s: %s", uidlist->path, error);