[dovecot-cvs] dovecot/src/lib-index mail-cache.c, 1.62,
1.63 mail-cache.h, 1.20, 1.21 mail-index.c, 1.186, 1.187
cras at dovecot.org
cras at dovecot.org
Mon Jan 31 20:03:46 EET 2005
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv7229/lib-index
Modified Files:
mail-cache.c mail-cache.h mail-index.c
Log Message:
Don't complain about cache indexid changing when recreating index.
Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- mail-cache.c 16 Jan 2005 19:18:24 -0000 1.62
+++ mail-cache.c 31 Jan 2005 18:03:43 -0000 1.63
@@ -222,12 +222,6 @@
static int mail_cache_open_and_verify(struct mail_cache *cache)
{
- cache->filepath = i_strconcat(cache->index->filepath,
- MAIL_CACHE_FILE_PREFIX, NULL);
-
- if (cache->index->mmap_disable || cache->index->mmap_no_write)
- cache->file_cache = file_cache_new(-1);
-
cache->fd = open(cache->filepath, O_RDWR);
if (cache->fd == -1) {
if (errno == ENOENT) {
@@ -248,13 +242,15 @@
return mail_cache_header_fields_read(cache);
}
-struct mail_cache *mail_cache_open_or_create(struct mail_index *index)
+static struct mail_cache *mail_cache_alloc(struct mail_index *index)
{
struct mail_cache *cache;
cache = i_new(struct mail_cache, 1);
cache->index = index;
cache->fd = -1;
+ cache->filepath =
+ i_strconcat(index->filepath, MAIL_CACHE_FILE_PREFIX, NULL);
cache->field_pool = pool_alloconly_create("Cache fields", 1024);
cache->field_name_hash =
hash_create(default_pool, cache->field_pool, 0,
@@ -265,11 +261,8 @@
cache->dotlock_settings.immediate_stale_timeout =
MAIL_CACHE_LOCK_IMMEDIATE_TIMEOUT;
- if (mail_cache_open_and_verify(cache) < 0) {
- /* failed for some reason - doesn't really matter,
- it's disabled for now. */
- mail_cache_file_close(cache);
- }
+ if (index->mmap_disable || index->mmap_no_write)
+ cache->file_cache = file_cache_new(-1);
cache->ext_id =
mail_index_ext_register(index, "cache", 0,
@@ -281,6 +274,7 @@
MAIL_INDEX_SYNC_HANDLER_INDEX |
(cache->file_cache == NULL ? 0 :
MAIL_INDEX_SYNC_HANDLER_VIEW));
+
if (cache->file_cache != NULL) {
mail_index_register_sync_lost_handler(index,
mail_cache_sync_lost_handler);
@@ -288,6 +282,28 @@
return cache;
}
+struct mail_cache *mail_cache_open_or_create(struct mail_index *index)
+{
+ struct mail_cache *cache;
+
+ cache = mail_cache_alloc(index);
+ if (mail_cache_open_and_verify(cache) < 0) {
+ /* failed for some reason - doesn't really matter,
+ it's disabled for now. */
+ mail_cache_file_close(cache);
+ }
+ return cache;
+}
+
+struct mail_cache *mail_cache_create(struct mail_index *index)
+{
+ struct mail_cache *cache;
+
+ cache = mail_cache_alloc(index);
+ cache->need_compress = TRUE;
+ return cache;
+}
+
void mail_cache_free(struct mail_cache *cache)
{
if (cache->file_cache != NULL) {
Index: mail-cache.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mail-cache.h 20 Jul 2004 16:50:56 -0000 1.20
+++ mail-cache.h 31 Jan 2005 18:03:43 -0000 1.21
@@ -39,6 +39,7 @@
};
struct mail_cache *mail_cache_open_or_create(struct mail_index *index);
+struct mail_cache *mail_cache_create(struct mail_index *index);
void mail_cache_free(struct mail_cache *cache);
/* Register fields. fields[].idx is updated to contain field index. */
Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -d -r1.186 -r1.187
--- mail-index.c 16 Jan 2005 18:41:58 -0000 1.186
+++ mail-index.c 31 Jan 2005 18:03:43 -0000 1.187
@@ -1189,7 +1189,7 @@
{
struct mail_index_header hdr;
unsigned int lock_id = 0;
- int ret;
+ int ret, created = FALSE;
ret = mail_index_try_open(index, &lock_id);
if (ret > 0)
@@ -1216,6 +1216,7 @@
}
if (mail_index_create(index, &hdr) < 0)
return -1;
+ created = TRUE;
}
if (lock_id == 0) {
@@ -1224,9 +1225,8 @@
}
- index->cache = mail_cache_open_or_create(index);
- if (index->cache == NULL)
- return -1;
+ index->cache = created ? mail_cache_create(index) :
+ mail_cache_open_or_create(index);
mail_index_unlock(index, lock_id);
return 1;
More information about the dovecot-cvs
mailing list