unsigned int remap_counter;
struct dotlock_settings dotlock_settings;
- struct dotlock *dotlock;
struct file_lock *file_lock;
/* mmap_disable=no: hdr points to data / NULL when cache is invalid.
nonblock = TRUE;
}
+ i_assert(cache->file_lock == NULL);
if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK) {
- i_assert(cache->file_lock == NULL);
timeout_secs = I_MIN(MAIL_CACHE_LOCK_TIMEOUT,
cache->index->max_lock_timeout_secs);
nonblock ? 0 : timeout_secs,
&cache->file_lock);
} else {
+ struct dotlock *dotlock;
enum dotlock_create_flags flags =
nonblock ? DOTLOCK_CREATE_FLAG_NONBLOCK : 0;
- i_assert(cache->dotlock == NULL);
ret = file_dotlock_create(&cache->dotlock_settings,
- cache->filepath, flags,
- &cache->dotlock);
- if (ret < 0) {
+ cache->filepath, flags, &dotlock);
+ if (ret > 0)
+ cache->file_lock = file_lock_from_dotlock(&dotlock);
+ else if (ret < 0) {
mail_cache_set_syscall_error(cache,
"file_dotlock_create()");
}
static void mail_cache_unlock_file(struct mail_cache *cache)
{
- if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK)
- file_unlock(&cache->file_lock);
- else
- file_dotlock_delete(&cache->dotlock);
+ file_unlock(&cache->file_lock);
}
static int