Return to IDLE properly when connection lulls

Commit 96aaf3 fixed a bug with regard to IDLE status responses being
improperly reported to ClientSession.  As it turned out, that fix
introduced a bug by not properly decrementing outstanding_cmds, which
left the ClientConnection in a state where it would never enter IDLE
thereafter.

The problem is a change I pondered at the time but didn't commit due
to that fix being so close to release time: not reporting the original
IDLE command to ClientSession either.  That in itself is harmless, but
not doing that also avoids incrementing outstanding_cmds for that
command, meaning when the IDLE completes that value returns to zero
and the ClientConnection is in an appropriate state to return to IDLE
when ready.
This commit is contained in:
Jim Nelson 2014-11-11 18:24:16 -08:00
parent 6b3db836ce
commit 2095ae955e

View file

@ -633,9 +633,6 @@ public class Geary.Imap.ClientConnection : BaseObject {
}
private async void do_flush_async() {
// need to signal when the IDLE command is sent, for completeness
IdleCommand? idle_cmd = null;
// Like send_async(), need to use mutex when flushing as Serializer must be accessed in
// serialized fashion
//
@ -714,7 +711,7 @@ public class Geary.Imap.ClientConnection : BaseObject {
// as connection is "quiet" (haven't seen new command in n msec), go into IDLE state
// if (a) allowed by owner, (b) allowed by state machine, and (c) no commands outstanding
if (ser != null && idle_when_quiet && outstanding_cmds == 0 && issue_conditional_event(Event.SEND_IDLE)) {
idle_cmd = new IdleCommand();
IdleCommand idle_cmd = new IdleCommand();
idle_cmd.assign_tag(generate_tag());
// store IDLE tag to watch for response later (many responses could arrive before it)
@ -733,7 +730,6 @@ public class Geary.Imap.ClientConnection : BaseObject {
assert(synchronize_tag == null);
}
} catch (Error err) {
idle_cmd = null;
send_failure(err);
} finally {
if (token != Nonblocking.Mutex.INVALID_TOKEN) {
@ -744,9 +740,6 @@ public class Geary.Imap.ClientConnection : BaseObject {
}
}
}
if (idle_cmd != null)
sent_command(idle_cmd);
}
private void check_for_connection() throws Error {