fs-posix.c (dovecot-2.3.16) | : | fs-posix.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 691 | skipping to change at line 691 | |||
} | } | |||
static int | static int | |||
fs_posix_lock(struct fs_file *_file, unsigned int secs, struct fs_lock **lock_r) | fs_posix_lock(struct fs_file *_file, unsigned int secs, struct fs_lock **lock_r) | |||
{ | { | |||
struct posix_fs_file *file = | struct posix_fs_file *file = | |||
container_of(_file, struct posix_fs_file, file); | container_of(_file, struct posix_fs_file, file); | |||
struct posix_fs *fs = container_of(_file->fs, struct posix_fs, fs); | struct posix_fs *fs = container_of(_file->fs, struct posix_fs, fs); | |||
struct dotlock_settings dotlock_set; | struct dotlock_settings dotlock_set; | |||
struct posix_fs_lock fs_lock, *ret_lock; | struct posix_fs_lock fs_lock, *ret_lock; | |||
const char *error; | ||||
int ret = -1; | int ret = -1; | |||
i_zero(&fs_lock); | i_zero(&fs_lock); | |||
fs_lock.lock.file = _file; | fs_lock.lock.file = _file; | |||
struct file_lock_settings lock_set = { | ||||
.lock_method = FILE_LOCK_METHOD_FLOCK, | ||||
}; | ||||
switch (fs->lock_method) { | switch (fs->lock_method) { | |||
case FS_POSIX_LOCK_METHOD_FLOCK: | case FS_POSIX_LOCK_METHOD_FLOCK: | |||
#ifndef HAVE_FLOCK | #ifndef HAVE_FLOCK | |||
fs_set_error(_file->event, ENOTSUP, | fs_set_error(_file->event, ENOTSUP, | |||
"flock() not supported by OS (for file %s)", | "flock() not supported by OS (for file %s)", | |||
file->full_path); | file->full_path); | |||
#else | #else | |||
if (secs == 0) { | if (secs == 0) { | |||
ret = file_try_lock(file->fd, file->full_path, F_WRLCK, | ret = file_try_lock(file->fd, file->full_path, F_WRLCK, | |||
FILE_LOCK_METHOD_FLOCK, | &lock_set, &fs_lock.file_lock, | |||
&fs_lock.file_lock); | &error); | |||
} else { | } else { | |||
ret = file_wait_lock(file->fd, file->full_path, F_WRLCK, | ret = file_wait_lock(file->fd, file->full_path, F_WRLCK, | |||
FILE_LOCK_METHOD_FLOCK, secs, | &lock_set, secs, | |||
&fs_lock.file_lock); | &fs_lock.file_lock, &error); | |||
} | } | |||
if (ret < 0) { | if (ret < 0) { | |||
fs_set_error_errno(_file->event, "flock(%s) failed: %m", | fs_set_error_errno(_file->event, "flock(%s) failed: %s", | |||
file->full_path); | file->full_path, error); | |||
} | } | |||
#endif | #endif | |||
break; | break; | |||
case FS_POSIX_LOCK_METHOD_DOTLOCK: | case FS_POSIX_LOCK_METHOD_DOTLOCK: | |||
i_zero(&dotlock_set); | i_zero(&dotlock_set); | |||
dotlock_set.stale_timeout = FS_POSIX_DOTLOCK_STALE_TIMEOUT_SECS; | dotlock_set.stale_timeout = FS_POSIX_DOTLOCK_STALE_TIMEOUT_SECS; | |||
dotlock_set.use_excl_lock = TRUE; | dotlock_set.use_excl_lock = TRUE; | |||
dotlock_set.timeout = secs; | dotlock_set.timeout = secs; | |||
ret = file_dotlock_create(&dotlock_set, file->full_path, | ret = file_dotlock_create(&dotlock_set, file->full_path, | |||
End of changes. 5 change blocks. | ||||
6 lines changed or deleted | 10 lines changed or added |