[balsa/gtk3] GdkThreads deprecation cleanup



commit 1c852540701c8c4fc43a45715dccbdcc6d8b5181
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Mar 19 20:11:31 2013 -0400

    GdkThreads deprecation cleanup
    
        * libbalsa/libbalsa.c (libbalsa_lock_mailbox),
        (libbalsa_unlock_mailbox): strip out GdkThreads-related code.
        * libbalsa/libbalsa.h: ditto.
        * libbalsa/mailbox.c (libbalsa_mailbox_msgno_find),
        (mbox_model_get_path), (libbalsa_mailbox_search_iter_step):
        ditto.
        * src/main.c (threads_init), (threads_destroy): ditto.

 ChangeLog           |   12 ++++++++++++
 libbalsa/libbalsa.c |   46 ++++------------------------------------------
 libbalsa/libbalsa.h |    4 ----
 libbalsa/mailbox.c  |    7 -------
 src/main.c          |    3 ---
 5 files changed, 16 insertions(+), 56 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6f9169a..9173b57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2013-03-19  Peter Bloomfield
 
+       GdkThreads deprecation cleanup
+
+       * libbalsa/libbalsa.c (libbalsa_lock_mailbox),
+       (libbalsa_unlock_mailbox): strip out GdkThreads-related code.
+       * libbalsa/libbalsa.h: ditto.
+       * libbalsa/mailbox.c (libbalsa_mailbox_msgno_find),
+       (mbox_model_get_path), (libbalsa_mailbox_search_iter_step):
+       ditto.
+       * src/main.c (threads_init), (threads_destroy): ditto.
+
+2013-03-19  Peter Bloomfield
+
        * src/main-window.c: use thread to check for new mail.
 
 2013-03-17  Peter Bloomfield
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index bb940a1..ba2fe62 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -67,7 +67,6 @@
 
 #ifdef BALSA_USE_THREADS
 static pthread_t main_thread_id;
-static pthread_t libbalsa_threads_id;
 #endif
 
 
@@ -694,25 +693,12 @@ void
 libbalsa_lock_mailbox(LibBalsaMailbox * mailbox)
 {
     pthread_t thread_id = pthread_self();
-    gint count = 0;
-
-    if (thread_id == libbalsa_threads_id
-        && thread_id == mailbox->thread_id
-        && mailbox->lock > 0) {
-        /* We already have both locks, so we'll just hold on to both of
-         * them. */
-        ++mailbox->lock;
-        return;
-    }
-
-    while (thread_id == libbalsa_threads_id) {
-        ++count;
-    }
 
     pthread_mutex_lock(&mailbox_mutex);
 
-    while (mailbox->lock && mailbox->thread_id != thread_id)
-        pthread_cond_wait(&mailbox_cond, &mailbox_mutex);
+    if (mailbox->thread_id && mailbox->thread_id != thread_id)
+        while (mailbox->lock)
+            pthread_cond_wait(&mailbox_cond, &mailbox_mutex);
 
     /* We'll assume that no-one would destroy a mailbox while we've been
      * trying to lock it. If they have, we have larger problems than
@@ -739,37 +725,13 @@ libbalsa_unlock_mailbox(LibBalsaMailbox * mailbox)
     }
 
     if(--mailbox->lock == 0) {
-        pthread_cond_broadcast(&mailbox_cond);
         mailbox->thread_id = 0;
+        pthread_cond_broadcast(&mailbox_cond);
     }
 
     pthread_mutex_unlock(&mailbox_mutex);
 }
 
-/* Recursive mutex for gdk_threads_{enter,leave}. */
-static pthread_mutex_t libbalsa_threads_mutex;
-static guint libbalsa_threads_lock;
-
-
-void
-libbalsa_threads_init(void)
-{
-    pthread_mutex_init(&libbalsa_threads_mutex, NULL);
-}
-
-void
-libbalsa_threads_destroy(void)
-{
-    pthread_mutex_destroy(&libbalsa_threads_mutex);
-}
-
-gboolean
-libbalsa_threads_has_lock(void)
-{
-    return TRUE || (libbalsa_threads_lock > 0
-                    && libbalsa_threads_id == pthread_self());
-}
-
 #endif                         /* BALSA_USE_THREADS */
 
 /* Initialized by the front end. */
diff --git a/libbalsa/libbalsa.h b/libbalsa/libbalsa.h
index bb6c292..7028ca3 100644
--- a/libbalsa/libbalsa.h
+++ b/libbalsa/libbalsa.h
@@ -143,12 +143,8 @@ gboolean libbalsa_abort_on_timeout(const char *host);
 #include <pthread.h>
 pthread_t libbalsa_get_main_thread(void);
 gboolean libbalsa_am_i_subthread(void);
-void libbalsa_threads_init(void);
-void libbalsa_threads_destroy(void);
-gboolean libbalsa_threads_has_lock(void);
 #else
 #define libbalsa_am_i_subthread() FALSE
-#define libbalsa_threads_has_lock() TRUE
 #endif /* BALSA_USE_THREADS */
 #if defined(BALSA_DEBUG_THREADS)
 #define gdk_threads_enter()                       \
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index d4956ea..bfed9cb 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1804,8 +1804,6 @@ libbalsa_mailbox_msgno_find(LibBalsaMailbox * mailbox, guint seqno,
 {
     GtkTreeIter tmp_iter;
 
-    if (!libbalsa_threads_has_lock())
-        g_warning("Thread is not holding gdk lock");
     g_return_val_if_fail(LIBBALSA_IS_MAILBOX(mailbox), FALSE);
     g_return_val_if_fail(seqno > 0, FALSE);
 
@@ -2894,8 +2892,6 @@ mbox_model_get_path(GtkTreeModel * tree_model, GtkTreeIter * iter)
     GNode *parent_node;
 #endif
 
-    if (!libbalsa_threads_has_lock())
-        g_warning("Thread is not holding gdk lock");
     g_return_val_if_fail(VALID_ITER(iter, tree_model), NULL);
 
     node = iter->user_data;
@@ -4334,9 +4330,6 @@ libbalsa_mailbox_search_iter_step(LibBalsaMailbox * mailbox,
     gboolean retval = FALSE;
     gint total;
 
-    if (!libbalsa_threads_has_lock())
-        g_warning("Thread is not holding gdk lock");
-
     node = iter->user_data;
     if (!node)
         node = mailbox->msg_tree;
diff --git a/src/main.c b/src/main.c
index 4701f2b..7793730 100644
--- a/src/main.c
+++ b/src/main.c
@@ -257,8 +257,6 @@ threads_init(void)
 {
     g_type_init();
 
-    libbalsa_threads_init();
-
     pthread_mutex_init(&send_messages_lock, NULL);
     if (pipe(mail_thread_pipes) < 0) {
        g_log("BALSA Init", G_LOG_LEVEL_DEBUG,
@@ -288,7 +286,6 @@ threads_destroy(void)
 {
     pthread_mutex_destroy(&checking_mail_lock);
     pthread_mutex_destroy(&send_messages_lock);
-    libbalsa_threads_destroy();
 }
 
 #endif                         /* BALSA_USE_THREADS */


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