*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);
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",
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;
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",
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);
*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 &&
}
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 */
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 *
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;
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);
/* 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);
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);
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);
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);