]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Misc. fixes.
authorTimo Sirainen <tss@iki.fi>
Sun, 18 May 2003 12:23:03 +0000 (15:23 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 18 May 2003 12:23:03 +0000 (15:23 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index-open.c
src/lib-index/mail-index.c
src/lib-index/mbox/mbox-index.c

index 98a89bee4fee885c121957c7a9e11067c3442dff..3fc62f4296c1169c22c35c40f47962de03c02f9f 100644 (file)
@@ -286,8 +286,10 @@ static int mail_index_create_memory(struct mail_index *index,
 
        index->mmap_full_length = INDEX_FILE_MIN_SIZE;
        index->mmap_base = mmap_anon(index->mmap_full_length);
-       if (index->mmap_base == MAP_FAILED)
+       if (index->mmap_base == MAP_FAILED) {
+               index->mmap_base = NULL;
                return index_set_error(index, "mmap_anon() failed: %m");
+       }
 
        mail_index_init_header(index, index->mmap_base);
        index->header = index->mmap_base;
@@ -332,7 +334,8 @@ static int mail_index_open_index(struct mail_index *index,
        if ((ret = mail_index_read_header(index, &hdr)) < 0)
                return FALSE;
 
-       if (ret == 0 || !mail_index_is_compatible(&hdr)) {
+       if (ret == 0 || !mail_index_is_compatible(&hdr) ||
+           (hdr.flags & MAIL_INDEX_FLAG_REBUILD) != 0) {
                if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
                        return FALSE;
 
index 60059e673004c701b213deb2b86dc33016344549..7efe0c8657c028ed13ec1e51d7cdc3994351f96f 100644 (file)
@@ -120,7 +120,19 @@ int mail_index_mmap_update(struct mail_index *index)
 
 void mail_index_close(struct mail_index *index)
 {
-       index->set_flags = 0;
+       if (index->set_flags != 0) {
+               if (index->header != NULL) {
+#ifdef DEBUG
+                       mprotect(index->mmap_base, index->mmap_used_length,
+                                PROT_READ|PROT_WRITE);
+#endif
+                       index->header->flags |= index->set_flags;
+                       (void)msync(index->mmap_base,
+                                   sizeof(struct mail_index_header), MS_SYNC);
+               }
+               index->set_flags = 0;
+       }
+
        index->set_cache_fields = 0;
 
        index->opened = FALSE;
@@ -170,11 +182,6 @@ void mail_index_close(struct mail_index *index)
                 index->custom_flags = NULL;
        }
 
-       if (index->control_dir != NULL) {
-               i_free(index->control_dir);
-                index->control_dir = NULL;
-       }
-
        if (index->error != NULL) {
                i_free(index->error);
                index->error = NULL;
index e6b8b8f0b84ed76fa7a7811bf1aca082737de233..e0b64b375b1f4e1b66c4dbddacaad341fd235d82 100644 (file)
@@ -771,6 +771,7 @@ static void mbox_index_free(struct mail_index *index)
        mail_index_close(index);
        i_free(index->dir);
        i_free(index->mailbox_path);
+       i_free(index->control_dir);
        i_free(index);
 }