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.
This commit is contained in:
Michael Gratton 2020-09-01 22:39:50 +10:00 committed by Michael James Gratton
parent 83156acf34
commit 67f0678b1d

View file

@ -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.