From 974dbc4b88fe7aced15a3f20c34dd07046535914 Mon Sep 17 00:00:00 2001
From: Phil <phil@secdev.org>
Date: Thu, 30 Apr 2009 16:11:54 +0200
Subject: [PATCH]  Simplify automaton control loop

---
 scapy/automaton.py | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/scapy/automaton.py b/scapy/automaton.py
index 3ccc52c0..f268f809 100644
--- a/scapy/automaton.py
+++ b/scapy/automaton.py
@@ -395,9 +395,8 @@ class Automaton:
     def do_control(self):
         singlestep = True
         self.debug(3, "Starting control thread [tid=%i]" % self.threadid)
-        stop = False
         try:
-            while not stop:
+            while True:
                 c = self.cmdin.recv()
                 self.debug(5, "Received command %s" % c.type)
                 if c.type == _ATMT_Command.RUN:
@@ -409,21 +408,15 @@ class Automaton:
                 while True:
                     try:
                         state = self.do_next()
-                    except KeyboardInterrupt:
-                        self.debug(1,"Interrupted by user")
-                        stop=True
-                        break
                     except self.CommandMessage:
                         break
-                    except StopIteration,e:
-                        c = Message(type=_ATMT_Command.END, result=e.args[0])
-                        self.cmdout.send(c)
-                        stop=True
-                        break
                     if singlestep:
                         c = Message(type=_ATMT_Command.SINGLESTEP,state=state)
                         self.cmdout.send(c)
                         break
+        except StopIteration,e:
+            c = Message(type=_ATMT_Command.END, result=e.args[0])
+            self.cmdout.send(c)
         except Exception,e:
             self.debug(3, "Transfering exception [%s] from tid=%i"% (e,self.threadid))
             m = Message(type = _ATMT_Command.EXCEPTION, exception=e)
-- 
GitLab