From: NeilBrown Date: Thu, 24 Jan 2013 23:38:03 +0000 (+1100) Subject: gsmd: handle suspend after setting the the timeout. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=218f528af3802613d37bc2d4532ef9e92c8a727f;p=plato.git gsmd: handle suspend after setting the the timeout. As soon as we acknowledge suspend, we might process an immediate resume. That will try to abort any timeout. So it is best to do it *after* we set our timeout, else we get stuck in that timeout and never abort it. Signed-off-by: NeilBrown --- diff --git a/gsm/gsmd.py b/gsm/gsmd.py index e451627..70c1ab9 100644 --- a/gsm/gsmd.py +++ b/gsm/gsmd.py @@ -952,14 +952,16 @@ class GsmD(AtChannel): self.lastrun = n * [0] t, delay = self.next_cmd() - if delay and self.suspend_pending: - self.suspend_pending = False - print "advance calls release" - self.suspend_handle.release() - if delay: log("Sleeping for %f seconds" % (delay/1000.0)) self.set_timeout(delay) + if self.suspend_pending: + # It is important that this comes after set_timeout + # as we might get an abort_timeout as a result of the + # release, and there needs to be a timeout to abort + self.suspend_pending = False + print "advance calls release" + self.suspend_handle.release() else: self.tasknum = t self.state = {}