when stopping the sender thread, ensure that no one is going to block on send_q. otherwise a ryu app who wants to do send_msg on the datapath can block on the queue forever if the queue is full.
Signed-off-by: YAMAMOTO Takashi <[email protected]> --- ryu/controller/controller.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index 7dc48c4..9dc745a 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -191,12 +191,19 @@ class Datapath(object): @_deactivate def _send_loop(self): - while self.is_active: - buf = self.send_q.get() - self.socket.sendall(buf) + try: + while self.is_active: + buf = self.send_q.get() + self.socket.sendall(buf) + finally: + q = self.send_q + self.send_q = None + while q.get(): + pass def send(self, buf): - self.send_q.put(buf) + if self.send_q: + self.send_q.put(buf) def set_xid(self, msg): self.xid += 1 -- 1.7.12 ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
