[geary/wip/only-incomplete] Potential fix for AccountSynchronizer deadlocking intemittently
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/only-incomplete] Potential fix for AccountSynchronizer deadlocking intemittently
- Date: Sat, 19 Apr 2014 02:51:32 +0000 (UTC)
commit cc0e22a306277ba4c712e8f91e0cd07983c33d0f
Author: Jim Nelson <jim yorba org>
Date: Fri Apr 18 19:51:14 2014 -0700
Potential fix for AccountSynchronizer deadlocking intemittently
.../imap-engine/imap-engine-email-prefetcher.vala | 32 +++++++++++++-------
.../nonblocking-counting-semaphore.vala | 4 ++
2 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-email-prefetcher.vala
b/src/engine/imap-engine/imap-engine-email-prefetcher.vala
index 1c25ed4..a671e64 100644
--- a/src/engine/imap-engine/imap-engine-email-prefetcher.vala
+++ b/src/engine/imap-engine/imap-engine-email-prefetcher.vala
@@ -69,10 +69,18 @@ private class Geary.ImapEngine.EmailPrefetcher : Object {
if (schedule_id != 0) {
Source.remove(schedule_id);
schedule_id = 0;
+
+ // since an acquire was done when scheduled, need to notify when cancelled
+ active_sem.blind_notify();
}
}
private void on_local_expansion(Gee.Collection<Geary.EmailIdentifier> ids) {
+ // it's possible to be notified of an append prior to remote open; don't prefetch until
+ // that occurs
+ if (folder.get_open_state() != Geary.Folder.OpenState.BOTH)
+ return;
+
// acquire here since .begin() only schedules for later
active_sem.acquire();
do_prepare_new_async.begin(ids);
@@ -88,20 +96,20 @@ private class Geary.ImapEngine.EmailPrefetcher : Object {
prefetch_emails.add_all(emails);
// only increment active state if not rescheduling
- if (schedule_id != 0)
+ if (schedule_id != 0) {
+ debug("Rescheduling prefetch task");
Source.remove(schedule_id);
- else
+ } else {
+ debug("Scheduling new prefetch task");
active_sem.acquire();
+ }
- schedule_id = Timeout.add_seconds(start_delay_sec, on_start_prefetch);
- }
-
- private bool on_start_prefetch() {
- do_prefetch_async.begin();
-
- schedule_id = 0;
-
- return false;
+ schedule_id = Timeout.add_seconds(start_delay_sec, () => {
+ schedule_id = 0;
+ do_prefetch_async.begin();
+
+ return false;
+ });
}
private async void do_prepare_all_local_async() {
@@ -123,9 +131,11 @@ private class Geary.ImapEngine.EmailPrefetcher : Object {
private async void do_prepare_new_async(Gee.Collection<Geary.EmailIdentifier> ids) {
Gee.List<Geary.Email>? list = null;
try {
+ debug("LIsting new %d emails needing prefetching in %s...", ids.size, folder.to_string());
list = yield folder.local_folder.list_email_by_sparse_id_async(
(Gee.Collection<ImapDB.EmailIdentifier>) ids,
Geary.Email.Field.PROPERTIES, ImapDB.Folder.ListFlags.ONLY_INCOMPLETE, cancellable);
+ debug("Listed new emails needing prefetching in %s", folder.to_string());
} catch (Error err) {
debug("Error while list local emails for %s: %s", folder.to_string(), err.message);
}
diff --git a/src/engine/nonblocking/nonblocking-counting-semaphore.vala
b/src/engine/nonblocking/nonblocking-counting-semaphore.vala
index fbaeb5c..fe58325 100644
--- a/src/engine/nonblocking/nonblocking-counting-semaphore.vala
+++ b/src/engine/nonblocking/nonblocking-counting-semaphore.vala
@@ -35,6 +35,8 @@ public class Geary.Nonblocking.CountingSemaphore : Geary.Nonblocking.AbstractSem
public int acquire() {
count++;
+ debug("CountingSemaphore acquired, new count=%d", count);
+
// store on stack in case of reentrancy from signal handler; also note that Vala doesn't
// deal well with properties, pre/post-inc, and assignment on same line
int new_count = count;
@@ -58,6 +60,8 @@ public class Geary.Nonblocking.CountingSemaphore : Geary.Nonblocking.AbstractSem
count--;
+ debug("CountingSempahore notified, new count=%d", count);
+
// store on stack in case of reentrancy from signal handler; also note that Vala doesn't
// deal well with properties, pre/post-inc, and assignment on same line
int new_count = count;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]