From: Timo Sirainen Date: Wed, 1 Apr 2020 19:24:59 +0000 (+0300) Subject: lib-index: Remove mail_cache_try_lock() X-Git-Tag: 2.3.11.2~379 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=106837930dde19ccc12eb7a729b1461c98b86c40;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Remove mail_cache_try_lock() --- diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index f7265b1ea3..d34a780d57 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -210,7 +210,6 @@ struct mail_cache_lookup_iterate_ctx { /* Explicitly lock the cache file. Returns -1 if error / timed out, 1 if ok, 0 if cache is broken/doesn't exist */ int mail_cache_lock(struct mail_cache *cache); -int mail_cache_try_lock(struct mail_cache *cache); /* Flush pending header updates and unlock. Returns -1 if cache is / just got corrupted, 0 if ok. */ int mail_cache_flush_and_unlock(struct mail_cache *cache); diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 2d24ce992a..48645db13e 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -611,9 +611,10 @@ void mail_cache_free(struct mail_cache **_cache) i_free(cache); } -static int mail_cache_lock_file(struct mail_cache *cache, bool nonblock) +static int mail_cache_lock_file(struct mail_cache *cache) { unsigned int timeout_secs; + bool nonblock = FALSE; int ret; if (cache->last_lock_failed) { @@ -706,7 +707,7 @@ mail_cache_sync_wait_index(struct mail_cache *cache, uint32_t *reset_id_r) whether the reset_id can be synced or if it's already desynced and the cache just needs to be recreated. */ ret = -1; - while (mail_cache_lock_file(cache, FALSE) > 0) { + while (mail_cache_lock_file(cache) > 0) { /* Locked the current fd, but it may have already been recreated. Reopen and retry if needed. */ if (!mail_cache_need_reopen(cache)) { @@ -766,8 +767,7 @@ int mail_cache_sync_reset_id(struct mail_cache *cache) return ret; } -static int -mail_cache_lock_full(struct mail_cache *cache, bool nonblock) +int mail_cache_lock(struct mail_cache *cache) { int ret; @@ -776,8 +776,6 @@ mail_cache_lock_full(struct mail_cache *cache, bool nonblock) if we're coming from mail_cache_expunge_count() while syncing the index. */ i_assert(!cache->index->mapping || cache->index->log_sync_locked); - /* No need to fully support nonblock=TRUE for now at least */ - i_assert(!nonblock || cache->index->log_sync_locked); if (MAIL_INDEX_IS_IN_MEMORY(cache->index) || cache->index->readonly) @@ -795,7 +793,7 @@ mail_cache_lock_full(struct mail_cache *cache, bool nonblock) } for (;;) { - if (mail_cache_lock_file(cache, nonblock) <= 0) + if (mail_cache_lock_file(cache) <= 0) return -1; if (!mail_cache_need_reopen(cache)) { /* locked the latest file */ @@ -833,16 +831,6 @@ mail_cache_lock_full(struct mail_cache *cache, bool nonblock) return 1; } -int mail_cache_lock(struct mail_cache *cache) -{ - return mail_cache_lock_full(cache, FALSE); -} - -int mail_cache_try_lock(struct mail_cache *cache) -{ - return mail_cache_lock_full(cache, TRUE); -} - int mail_cache_flush_and_unlock(struct mail_cache *cache) { int ret = 0;