[balsa] Guard against mailbox changes
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Guard against mailbox changes
- Date: Fri, 10 Jan 2020 23:10:17 +0000 (UTC)
commit d9b18d2356ccb1620e59bc90293516da5313f174
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Jan 10 15:26:59 2020 -0500
Guard against mailbox changes
Guard against mailbox being closed or finalized during a call to
libbalsa_progress_set_fraction().
* libbalsa/mailbox.c (lbm_run_filters_on_reception_idle_cb):
* libbalsa/mailbox_local.c (lbm_local_update_view_filter),
(libbalsa_mailbox_local_prepare_threading):
ChangeLog | 9 +++++++++
libbalsa/mailbox.c | 25 ++++++++++++++++++++-----
libbalsa/mailbox_local.c | 10 +++++++---
3 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 51c1aa86d..ff69f0ae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-01-10 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Guard against mailbox being closed or finalized during a call to
+ libbalsa_progress_set_fraction().
+
+ * libbalsa/mailbox.c (lbm_run_filters_on_reception_idle_cb):
+ * libbalsa/mailbox_local.c (lbm_local_update_view_filter),
+ (libbalsa_mailbox_local_prepare_threading):
+
2020-01-09 Peter Bloomfield <pbloomfield bellsouth net>
mailbox: Check whether the mailbox was closed during
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 0fb2594f0..d595f7508 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -842,6 +842,8 @@ lbm_run_filters_on_reception_idle_cb(LibBalsaMailbox * mailbox)
guint total;
guint progress_total;
LibBalsaProgress progress;
+ gboolean is_mailbox = TRUE;
+ gboolean is_open = TRUE;
libbalsa_lock_mailbox(mailbox);
@@ -923,21 +925,34 @@ lbm_run_filters_on_reception_idle_cb(LibBalsaMailbox * mailbox)
/
((gdouble) progress_total));
/* mailbox could have been closed during set-fraction */
- if (priv->state != LB_MAILBOX_STATE_OPEN)
+ if (!LIBBALSA_IS_MAILBOX(mailbox))
+ is_open = is_mailbox = FALSE;
+ else if (!LIBBALSA_MAILBOX_OPEN(mailbox))
+ is_open = FALSE;
+
+ if (!is_open)
break;
}
}
libbalsa_mailbox_search_iter_unref(search_iter);
- libbalsa_mailbox_register_msgnos(mailbox, msgnos);
- libbalsa_filter_mailbox_messages(filter, mailbox, msgnos);
- libbalsa_mailbox_unregister_msgnos(mailbox, msgnos);
+ if (is_open) {
+ libbalsa_mailbox_register_msgnos(mailbox, msgnos);
+ libbalsa_filter_mailbox_messages(filter, mailbox, msgnos);
+ libbalsa_mailbox_unregister_msgnos(mailbox, msgnos);
+ }
+
g_array_free(msgnos, TRUE);
+
+ if (!is_open)
+ break;
}
libbalsa_progress_set_text(&progress, NULL, 0);
g_slist_free(filters);
- libbalsa_unlock_mailbox(mailbox);
+
+ if (is_mailbox)
+ libbalsa_unlock_mailbox(mailbox);
return FALSE;
}
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 39e2a396c..8ef0e5e88 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -1270,13 +1270,15 @@ lbm_local_update_view_filter(LibBalsaMailbox * mailbox,
FALSE);
libbalsa_progress_set_fraction(&progress, ((gdouble) msgno) /
((gdouble) total));
+ if (!LIBBALSA_IS_MAILBOX(mailbox) || !MAILBOX_OPEN(mailbox))
+ break;
}
libbalsa_progress_set_text(&progress, NULL, 0);
libbalsa_mailbox_search_iter_unref(iter_view);
/* If this is not a flags-only filter, the new mailbox tree is
* temporary, so we don't want to save it. */
- if (is_flag_only)
+ if (is_flag_only && LIBBALSA_IS_MAILBOX(mailbox))
lbm_local_queue_save_tree(LIBBALSA_MAILBOX_LOCAL(mailbox));
}
@@ -1360,7 +1362,7 @@ libbalsa_mailbox_local_prepare_threading(LibBalsaMailbox * mailbox,
libbalsa_progress_set_fraction(&progress,
((gdouble) msgno) /
((gdouble) (total - start)));
- if (!MAILBOX_OPEN(mailbox)) {
+ if (!LIBBALSA_IS_MAILBOX(mailbox) || !MAILBOX_OPEN(mailbox)) {
/* Mailbox was closed during set-fraction. */
retval = FALSE;
break;
@@ -1380,7 +1382,9 @@ libbalsa_mailbox_local_prepare_threading(LibBalsaMailbox * mailbox,
g_idle_add((GSourceFunc) lbm_local_thread_idle, local);
}
}
- libbalsa_unlock_mailbox(mailbox);
+
+ if (LIBBALSA_IS_MAILBOX(mailbox))
+ libbalsa_unlock_mailbox(mailbox);
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]