[geary/mjog/imap-command-cancellation: 1/6] Geary.Imap: Don't cancel waiting for responses for submitted commands
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/imap-command-cancellation: 1/6] Geary.Imap: Don't cancel waiting for responses for submitted commands
- Date: Wed, 2 Sep 2020 06:03:49 +0000 (UTC)
commit 67f0678b1d13f5192f06b03da505a1a8e4029aa7
Author: Michael Gratton <mike vee net>
Date: Tue Sep 1 22:39:50 2020 +1000
Geary.Imap: Don't cancel waiting for responses for submitted commands
The IMAP protocol does not allow commands to be cancelled once sent over
the wire to the server. However `IMAP.Command` objects are currently
submitted to be send with a cancellable, which may be cancelled before
the response is received from the server. If this happens, the repsonse
to the command from the server is not waited for, and untagged data from
the cancelled command may end up being handled by the subsequent
command, which is bad.
After submitting a command to the connection, don't supply the given
cancellable to the command's wait method, so it hangs around to handle
any tagged and untagged responses as required.
src/engine/imap/transport/imap-client-session.vala | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/engine/imap/transport/imap-client-session.vala
b/src/engine/imap/transport/imap-client-session.vala
index 27e84837c..6edbacf09 100644
--- a/src/engine/imap/transport/imap-client-session.vala
+++ b/src/engine/imap/transport/imap-client-session.vala
@@ -1785,7 +1785,12 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
throw new ImapError.NOT_CONNECTED("Not connected to %s", imap_endpoint.to_string());
this.cx.send_command(cmd);
- yield cmd.wait_until_complete(cancellable);
+
+ // Once a command has been sent over the wire, it can't be
+ // cancelled until a response is received, because the server
+ // will send a response back anyway and so the command needs
+ // to be around for it.
+ yield cmd.wait_until_complete(null);
// This won't be null since the Command.wait_until_complete
// will throw an error if it is.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]