2007-01-13 [colin] 2.7.0cvs19
authorColin Leroy <colin@colino.net>
Sat, 13 Jan 2007 13:25:08 +0000 (13:25 +0000)
committerColin Leroy <colin@colino.net>
Sat, 13 Jan 2007 13:25:08 +0000 (13:25 +0000)
* src/etpan/imap-thread.c
Make sure we don't free the same imap
twice

ChangeLog
PATCHSETS
configure.ac
src/etpan/imap-thread.c

index 9dd29005c3e9de7d7003dee2ea9ea70d50c849ab..49cb993829290af5f78dc101ae91238bf8e6c6b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-13 [colin]     2.7.0cvs19
+
+       * src/etpan/imap-thread.c
+               Make sure we don't free the same imap
+               twice
+
 2007-01-13 [colin]     2.7.0cvs18
 
        * commitHelper
index 105eba9cd8dc925c7bd3f87a578c7a94a2dea682..0e60f781ad4acda913e4a1ac750bcf6f3f497f9e 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.350 -r 1.382.2.351 src/compose.c;  ) > 2.7.0cvs16.patchset
 ( cvs diff -u -r 1.1.4.63 -r 1.1.4.64 src/etpan/imap-thread.c;  ) > 2.7.0cvs17.patchset
 ( cvs diff -u -r 1.1.2.33 -r 1.1.2.34 commitHelper;  ) > 2.7.0cvs18.patchset
+( cvs diff -u -r 1.1.4.64 -r 1.1.4.65 src/etpan/imap-thread.c;  ) > 2.7.0cvs19.patchset
index 4f810933d238f9024bfae3c370b07ff17a77ff7c..63acaa54f17e4d886248a50d4d74c6da13bf64e4 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=7
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=18
+EXTRA_VERSION=19
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index b1299010fdb65147eb8df18aa6d00f9f382bcdab..7726100f068853d6774233709b24342f0372dc7a 100644 (file)
@@ -31,6 +31,23 @@ static chash * session_hash = NULL;
 static guint thread_manager_signal = 0;
 static GIOChannel * io_channel = NULL;
 
+void delete_imap(Folder *folder, mailimap *imap)
+{
+       chashdatum key;
+       chashdatum value;
+
+       key.data = &folder;
+       key.len = sizeof(folder);
+       value.data = imap;
+       value.len = 0;
+       chash_delete(session_hash, &key, NULL);
+       
+       key.data = &imap;
+       key.len = sizeof(imap);
+       chash_delete(courier_workaround_hash, &key, NULL);
+       debug_print("removing mailimap %p\n", imap);
+       mailimap_free(imap);    
+}
 
 static gboolean thread_manager_event(GIOChannel * source,
     GIOCondition condition,
@@ -417,13 +434,8 @@ int imap_threaded_connect(Folder * folder, const char * server, int port)
        
        imap = get_imap(folder);
        if (imap) {
-               key.data = &folder;
-               key.len = sizeof(folder);
-               value.data = imap;
-               value.len = 0;
-               chash_delete(session_hash, &key, NULL);
-               mailimap_free(imap);
-               debug_print("deleted old imap\n");
+               debug_print("deleting old imap %p\n", imap);
+               delete_imap(folder, imap);
        }
 
        imap = mailimap_new(0, NULL);
@@ -501,13 +513,8 @@ int imap_threaded_connect_ssl(Folder * folder, const char * server, int port)
 
        imap = get_imap(folder);
        if (imap) {
-               key.data = &folder;
-               key.len = sizeof(folder);
-               value.data = imap;
-               value.len = 0;
-               chash_delete(session_hash, &key, NULL);
-               mailimap_free(imap);
-               debug_print("deleted old imap\n");
+               debug_print("deleting old imap %p\n", imap);
+               delete_imap(folder, imap);
        }
 
        imap = mailimap_new(0, NULL);
@@ -615,8 +622,6 @@ void imap_threaded_disconnect(Folder * folder)
 {
        struct connect_param param;
        struct connect_result result;
-       chashdatum key;
-       chashdatum value;
        mailimap * imap;
        
        imap = get_imap(folder);
@@ -629,17 +634,12 @@ void imap_threaded_disconnect(Folder * folder)
        
        threaded_run(folder, &param, &result, disconnect_run);
        
-       key.data = &folder;
-       key.len = sizeof(folder);
-       value.data = imap;
-       value.len = 0;
-       chash_delete(session_hash, &key, NULL);
-       
-       key.data = &imap;
-       key.len = sizeof(imap);
-       chash_delete(courier_workaround_hash, &key, NULL);
-       
-       mailimap_free(imap);
+       if (imap == get_imap(folder)) {
+               debug_print("deleting old imap %p\n", imap);
+               delete_imap(folder, imap);
+       } else {
+               debug_print("imap already deleted %p\n", imap);
+       }
        
        debug_print("disconnect ok\n");
 }
@@ -2730,13 +2730,8 @@ int imap_threaded_connect_cmd(Folder * folder, const char * command,
        
        imap = get_imap(folder);
        if (imap) {
-               key.data = &folder;
-               key.len = sizeof(folder);
-               value.data = imap;
-               value.len = 0;
-               chash_delete(session_hash, &key, NULL);
-               mailimap_free(imap);
-               debug_print("deleted old imap\n");
+               debug_print("deleting old imap %p\n", imap);
+               delete_imap(folder, imap);
        }
 
        imap = mailimap_new(0, NULL);