[dovecot-cvs] dovecot/src/lib-index mail-cache.c,1.93,1.94
tss at dovecot.org
tss at dovecot.org
Fri Feb 16 10:55:02 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv1290
Modified Files:
mail-cache.c
Log Message:
Allocate cache file's size amount of memory for the file cache so it doesn't
have to grow it constantly while reading the file.
Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- mail-cache.c 16 Jan 2007 22:00:18 -0000 1.93
+++ mail-cache.c 16 Feb 2007 10:55:00 -0000 1.94
@@ -70,6 +70,21 @@
}
}
+static void mail_cache_init_file_cache(struct mail_cache *cache)
+{
+ struct stat st;
+
+ if (cache->file_cache == NULL)
+ return;
+
+ file_cache_set_fd(cache->file_cache, cache->fd);
+
+ if (fstat(cache->fd, &st) < 0)
+ mail_cache_set_syscall_error(cache, "fstat()");
+ else
+ file_cache_set_size(cache->file_cache, st.st_size);
+}
+
int mail_cache_reopen(struct mail_cache *cache)
{
struct mail_index_view *view;
@@ -95,8 +110,7 @@
return -1;
}
- if (cache->file_cache != NULL)
- file_cache_set_fd(cache->file_cache, cache->fd);
+ mail_cache_init_file_cache(cache);
if (mail_cache_map(cache, 0, 0) < 0)
return -1;
@@ -270,8 +284,7 @@
return -1;
}
- if (cache->file_cache != NULL)
- file_cache_set_fd(cache->file_cache, cache->fd);
+ mail_cache_init_file_cache(cache);
if (mail_cache_map(cache, 0, sizeof(struct mail_cache_header)) < 0)
return -1;
More information about the dovecot-cvs
mailing list