]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
when index's header size grows, fix it first time we get exclusive lock
authorTimo Sirainen <tss@iki.fi>
Sun, 23 May 2004 23:52:15 +0000 (02:52 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 23 May 2004 23:52:15 +0000 (02:52 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index-lock.c

index eb7937a93df2b2c43f24c8ccc323e6253433823d..0c6ead1ed22f8c8ba7bbac67d65d9464b7516dad 100644 (file)
@@ -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;