From: Timo Sirainen Date: Sun, 23 May 2004 23:52:15 +0000 (+0300) Subject: when index's header size grows, fix it first time we get exclusive lock X-Git-Tag: 1.1.alpha1~4058 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8521a231b063d62cc194b5ca40427225a069352;p=thirdparty%2Fdovecot%2Fcore.git when index's header size grows, fix it first time we get exclusive lock --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index-lock.c b/src/lib-index/mail-index-lock.c index eb7937a93d..0c6ead1ed2 100644 --- a/src/lib-index/mail-index-lock.c +++ b/src/lib-index/mail-index-lock.c @@ -344,12 +344,16 @@ int mail_index_lock_exclusive(struct mail_index *index, for the main index file */ i_assert(index->log_locked); - /* wait two seconds for exclusive lock */ - ret = mail_index_lock(index, F_WRLCK, 2, TRUE, lock_id_r); - if (ret > 0) - return 0; - if (ret < 0) - return -1; + /* if header size is smaller than what we have, we'll have to recreate + the index to grow it. so don't even try regular locking. */ + if (index->hdr->header_size >= sizeof(*index->hdr)) { + /* wait two seconds for exclusive lock */ + ret = mail_index_lock(index, F_WRLCK, 2, TRUE, lock_id_r); + if (ret > 0) + return 0; + if (ret < 0) + return -1; + } if (mail_index_lock_exclusive_copy(index) < 0) return -1;