[geary/geary-0.13] Merge branch 'wip/285-cancelled-commands' into 'master'
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/geary-0.13] Merge branch 'wip/285-cancelled-commands' into 'master'
- Date: Thu, 7 Mar 2019 00:50:52 +0000 (UTC)
commit 1387fb644c8ce807779371e7b36b28af59970359
Author: Michael Gratton <mike vee net>
Date: Thu Mar 7 00:49:14 2019 +0000
Merge branch 'wip/285-cancelled-commands' into 'master'
Ensure that cancelled commands throw a cancelled error, not a timeout
Closes #285
See merge request GNOME/geary!167
(cherry picked from commit 54f5ec397e4f78d698271c70a2c807cd190f177b)
2c8a232f Ensure that cancelled commands throw a cancelled error, not a timeout
src/engine/imap/command/imap-command.vala | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/imap/command/imap-command.vala b/src/engine/imap/command/imap-command.vala
index dd6eb18d..76964b17 100644
--- a/src/engine/imap/command/imap-command.vala
+++ b/src/engine/imap/command/imap-command.vala
@@ -79,6 +79,7 @@ public class Geary.Imap.Command : BaseObject {
new Geary.Nonblocking.Semaphore();
private bool timed_out = false;
+ private bool cancelled = false;
private Geary.Nonblocking.Spinlock? literal_spinlock = null;
private GLib.Cancellable? literal_cancellable = null;
@@ -209,10 +210,12 @@ public class Geary.Imap.Command : BaseObject {
* Cancels this command's execution.
*
* When this method is called, all locks will be released,
- * including {@link wait_until_complete}.
+ * including {@link wait_until_complete}, which will then throw a
+ * `GLib.IOError.CANCELLED` error.
*/
internal virtual void cancel_command() {
cancel_send();
+ this.cancelled = true;
this.response_timer.reset();
this.complete_lock.blind_notify();
}
@@ -220,17 +223,23 @@ public class Geary.Imap.Command : BaseObject {
/**
* Yields until the command has been completed or cancelled.
*
- * Throws an error if cancelled, if the command is cancelled, or
- * if the command's response was bad.
+ * Throws an error if the command or the cancellable argument is
+ * cancelled, if the command timed out, or if the command's
+ * response was bad.
*/
public async void wait_until_complete(GLib.Cancellable cancellable)
throws GLib.Error {
yield this.complete_lock.wait_async(cancellable);
+ if (this.cancelled) {
+ throw new GLib.IOError.CANCELLED(
+ "%s: Command was cancelled", to_brief_string()
+ );
+ }
+
if (this.timed_out) {
throw new ImapError.TIMED_OUT(
- "%s: No command response was received",
- to_brief_string()
+ "%s: Command timed out", to_brief_string()
);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]