]> git.neil.brown.name Git - plato.git/commitdiff
gsmd: handle suspend after setting the the timeout.
authorNeilBrown <neilb@suse.de>
Thu, 24 Jan 2013 23:38:03 +0000 (10:38 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 24 Jan 2013 23:38:03 +0000 (10:38 +1100)
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 <neilb@suse.de>
gsm/gsmd.py

index e45162798b46bd82aba8971f752fd7698fda279a..70c1ab9e086c9666ea07454da70f820380db186d 100644 (file)
@@ -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 = {}