[balsa] mailbox: lock the mailbox from start to finish



commit 7f28ebeb1b58d2dbbaa357ad6186b414874999f9
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Jan 27 20:33:06 2020 -0500

    mailbox: lock the mailbox from start to finish
    
    * libbalsa/mailbox.c (libbalsa_mailbox_msgno_inserted): lock the
      mailbox from start to finish, not just to access the private structure.

 ChangeLog          | 6 ++++++
 libbalsa/mailbox.c | 9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ad5441a1..03bf7a345 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-01-27  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * libbalsa/mailbox.c (libbalsa_mailbox_msgno_inserted): lock the
+       mailbox from start to finish, not just to access the private
+       structure.
+
 2020-01-27  Albrecht Dreß  <albrecht dress arcor de>
 
        Unify wrapped label creation
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 3482a4090..fac14fc0f 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1405,8 +1405,12 @@ libbalsa_mailbox_msgno_inserted(LibBalsaMailbox *mailbox, guint seqno,
     GtkTreeIter iter;
     GtkTreePath *path;
 
-    if (!priv->msg_tree)
+    libbalsa_lock_mailbox(mailbox);
+
+    if (priv->msg_tree == NULL) {
+        libbalsa_unlock_mailbox(mailbox);
         return;
+    }
 #undef SANITY_CHECK
 #ifdef SANITY_CHECK
     g_return_if_fail(!g_node_find(priv->msg_tree,
@@ -1428,14 +1432,13 @@ libbalsa_mailbox_msgno_inserted(LibBalsaMailbox *mailbox, guint seqno,
         gtk_tree_path_free(path);
     }
 
-    libbalsa_lock_mailbox(mailbox);
     if (priv->need_threading_idle_id == 0) {
         priv->need_threading_idle_id =
             g_idle_add((GSourceFunc) lbm_need_threading_idle_cb, mailbox);
     }
-    libbalsa_unlock_mailbox(mailbox);
 
     priv->msg_tree_changed = TRUE;
+    libbalsa_unlock_mailbox(mailbox);
 }
 
 static void


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