[geary] Further fixes to the background flag watcher
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Further fixes to the background flag watcher
- Date: Thu, 6 Feb 2014 20:00:47 +0000 (UTC)
commit 74ec08e0bd08db71352450e47cbb46ac0031170d
Author: Jim Nelson <jim yorba org>
Date: Thu Feb 6 11:52:16 2014 -0800
Further fixes to the background flag watcher
The "enabled" property is no longer used, so removing.
If the flag watcher is cancelled (because the folder has been closed),
the watcher was still rescheduling another polling loop. This patch
prevents that.
.../imap-engine-email-flag-watcher.vala | 21 ++++++++-----------
1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-email-flag-watcher.vala
b/src/engine/imap-engine/imap-engine-email-flag-watcher.vala
index ced046c..8c56fb6 100644
--- a/src/engine/imap-engine/imap-engine-email-flag-watcher.vala
+++ b/src/engine/imap-engine/imap-engine-email-flag-watcher.vala
@@ -19,8 +19,6 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
private const int PULL_CHUNK_COUNT = 100;
- public bool enabled { get; set; default = true; }
-
private unowned Geary.Folder folder;
private int seconds;
private uint watch_id = 0;
@@ -69,8 +67,7 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
}
private bool on_opened_update_flags() {
- if (enabled)
- flag_watch_async.begin();
+ flag_watch_async.begin();
// this callback was immediately called due to open, schedule next ones for here on out
// on a timer
@@ -80,11 +77,6 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
}
private bool on_flag_watch() {
- if (!enabled) {
- // try again later
- return true;
- }
-
flag_watch_async.begin();
watch_id = 0;
@@ -94,17 +86,22 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
}
private async void flag_watch_async() {
- if (!in_flag_watch) {
+ // prevent reentrancy and don't run if folder is closed
+ if (!in_flag_watch && !cancellable.is_cancelled()) {
in_flag_watch = true;
try {
yield do_flag_watch_async();
} catch (Error err) {
- message("Flag watch error: %s", err.message);
+ if (!(err is IOError.CANCELLED))
+ debug("%s flag watch error: %s", folder.to_string(), err.message);
+ else
+ debug("%s flag watch cancelled", folder.to_string());
}
in_flag_watch = false;
}
- if (watch_id == 0)
+ // reschedule if not already, and if not cancelled (folder is closed)
+ if (watch_id == 0 && !cancellable.is_cancelled())
watch_id = Timeout.add_seconds(seconds, on_flag_watch);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]