[dovecot-cvs]
dovecot/src/lib-storage/index index-storage.c,1.39,1.40
index-storage.h,1.49,1.50
cras at procontrol.fi
cras at procontrol.fi
Tue Sep 23 23:34:36 EEST 2003
Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv18492/lib-storage/index
Modified Files:
index-storage.c index-storage.h
Log Message:
Fixes memory/fd leaking with INDEX=MEMORY.
Index: index-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- index-storage.c 6 Aug 2003 20:15:33 -0000 1.39
+++ index-storage.c 23 Sep 2003 19:34:34 -0000 1.40
@@ -57,27 +57,31 @@
indexes = list;
}
-struct mail_index *index_storage_lookup_ref(const char *path)
+struct mail_index *
+index_storage_lookup_ref(const char *index_dir, const char *path)
{
struct index_list **list, *rec;
struct mail_index *match;
struct stat st1, st2;
int destroy_count;
- if (stat(path, &st1) < 0)
- return NULL;
+ if (index_dir != NULL) {
+ if (stat(index_dir, &st1) < 0)
+ return NULL;
+ }
- /* compare inodes so we don't break even with symlinks */
+ /* compare index_dir inodes so we don't break even with symlinks.
+ for in-memory indexes compare just mailbox paths */
destroy_count = 0; match = NULL;
for (list = &indexes; *list != NULL;) {
rec = *list;
- if (stat(rec->index->dir, &st2) == 0) {
- if (st1.st_ino == st2.st_ino &&
- st1.st_dev == st2.st_dev) {
- rec->refcount++;
- match = rec->index;
- }
+ if ((index_dir != NULL && stat(rec->index->dir, &st2) == 0 &&
+ st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev) ||
+ (index_dir == NULL &&
+ strcmp(path, rec->index->mailbox_path) == 0)) {
+ rec->refcount++;
+ match = rec->index;
}
if (rec->refcount == 0) {
Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- index-storage.h 24 Aug 2003 12:58:13 -0000 1.49
+++ index-storage.h 23 Sep 2003 19:34:34 -0000 1.50
@@ -55,7 +55,8 @@
enum mail_lock_type lock_type);
void index_storage_add(struct mail_index *index);
-struct mail_index *index_storage_lookup_ref(const char *path);
+struct mail_index *
+index_storage_lookup_ref(const char *index_dir, const char *path);
void index_storage_unref(struct mail_index *index);
void index_storage_destroy_unrefed(void);
More information about the dovecot-cvs
mailing list