From 218f528af3802613d37bc2d4532ef9e92c8a727f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 25 Jan 2013 10:38:03 +1100 Subject: [PATCH] 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 --- gsm/gsmd.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 = {} -- 2.39.5