[balsa/gtk3] Avoid blocking main thread



commit bb548cd84ae1471c91e38e3bb991925cfe8834b2
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Thu May 16 18:30:12 2013 -0400

    Avoid blocking main thread
    
        * libbalsa/imap/imap-handle.c (idle_start): use try-lock to
        avoid blocking main thread;
        (imap_handle_idle_enable): use g_timeout_add_seconds.

 ChangeLog                   |    6 ++++++
 libbalsa/imap/imap-handle.c |    5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 83ed757..1c19dc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2013-05-16  Peter Bloomfield
 
+       * libbalsa/imap/imap-handle.c (idle_start): use try-lock to
+       avoid blocking main thread;
+       (imap_handle_idle_enable): use g_timeout_add_seconds.
+
+2013-05-16  Peter Bloomfield
+
        * libbalsa/mailbox.h: scrap
        LibBalsaMailboxView::mailing_list_address.
        * libbalsa/mailbox.c (libbalsa_mailbox_view_free): ditto.
diff --git a/libbalsa/imap/imap-handle.c b/libbalsa/imap/imap-handle.c
index 8c18cb1..e3069dc 100644
--- a/libbalsa/imap/imap-handle.c
+++ b/libbalsa/imap/imap-handle.c
@@ -446,7 +446,8 @@ idle_start(gpointer data)
 
   /* The test below can probably be weaker since it is ok for the
      channel to get disconnected before IDLE gets activated */
-  HANDLE_LOCK(h);
+  if(HANDLE_TRYLOCK(h) != 0)
+    return TRUE;/* Don't block, just try again later. */
   IMAP_REQUIRED_STATE3(h, IMHS_CONNECTED, IMHS_AUTHENTICATED,
                        IMHS_SELECTED, FALSE);
 
@@ -503,7 +504,7 @@ imap_handle_idle_enable(ImapMboxHandle *h, int seconds)
     return FALSE;
   }
   if(!h->idle_enable_id)
-    h->idle_enable_id = g_timeout_add(seconds*1000, idle_start, h);
+    h->idle_enable_id = g_timeout_add_seconds(seconds, idle_start, h);
   return TRUE;
 }
 


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