balsa r8086 - in trunk: . libbalsa/imap



Author: pawels
Date: Thu Feb 26 20:35:53 2009
New Revision: 8086
URL: http://svn.gnome.org/viewvc/balsa?rev=8086&view=rev

Log:
* libbalsa/imap/imap-commands.c: do not deadlock when opening imap
  mailbox with new messages, sorted on the client side.


Modified:
   trunk/ChangeLog
   trunk/libbalsa/imap/imap-commands.c

Modified: trunk/libbalsa/imap/imap-commands.c
==============================================================================
--- trunk/libbalsa/imap/imap-commands.c	(original)
+++ trunk/libbalsa/imap/imap-commands.c	Thu Feb 26 20:35:53 2009
@@ -1013,9 +1013,10 @@
   return rc;
 }
 
-ImapResponse
-imap_mbox_handle_fetch_set(ImapMboxHandle* handle,
-                           unsigned *set, unsigned cnt, ImapFetchType ift)
+static ImapResponse
+imap_mbox_handle_fetch_set_unlocked(ImapMboxHandle* handle,
+				    unsigned *set, unsigned cnt,
+				    ImapFetchType ift)
 {
   gchar * seq;
   ImapResponse rc;
@@ -1033,15 +1034,24 @@
   if(seq) {
     const char* hdr[13];
     ic_construct_header_list(hdr, fd.fd.req_fetch_type);
-    HANDLE_LOCK(handle);
     rc = imap_mbox_handle_fetch(handle, seq, hdr);
     if(rc == IMR_OK) set_avail_headers(handle, seq, fd.fd.req_fetch_type);
-    HANDLE_UNLOCK(handle);
     g_free(seq);
   } else rc = IMR_OK;
   return rc;
 }
 
+ImapResponse
+imap_mbox_handle_fetch_set(ImapMboxHandle* handle,
+                           unsigned *set, unsigned cnt, ImapFetchType ift)
+{
+  ImapResponse rc;
+  HANDLE_LOCK(handle);
+  rc = imap_mbox_handle_fetch_set_unlocked(handle, set, cnt, ift);
+  HANDLE_UNLOCK(handle);
+  return rc;
+}
+
 static void
 write_nstring(unsigned seqno, ImapFetchBodyType body_type,
               const char *str, size_t len, void *fl)
@@ -1779,8 +1789,8 @@
     qsort(seqno_to_fetch, fetch_cnt, sizeof(unsigned), comp_unsigned);
     printf("Should the client side sorting code "
            "be sorry about your bandwidth usage?\n");
-    rc = imap_mbox_handle_fetch_set(handle, seqno_to_fetch,
-                                    fetch_cnt, fetch_type);
+    rc = imap_mbox_handle_fetch_set_unlocked(handle, seqno_to_fetch,
+					     fetch_cnt, fetch_type);
     if(rc != IMR_OK)
       return rc;
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]