From fe6f94434cf968c2fb836cb0d29dfded40e468fc Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 25 Apr 2013 16:08:25 +0900 Subject: controller: fix send queue draining again and this time add comments to explain the intention. Signed-off-by: YAMAMOTO Takashi Signed-off-by: FUJITA Tomonori --- ryu/controller/controller.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index 4d0ccdff..7fe5ac9b 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -196,7 +196,16 @@ class Datapath(object): buf = self.send_q.get() self.socket.sendall(buf) finally: + q = self.send_q + # first, clear self.send_q to prevent new references. self.send_q = None + # there might be threads currently blocking in send_q.put(). + # unblock them by draining the queue. + try: + while q.get(block=False): + pass + except hub.QueueEmpty: + pass def send(self, buf): if self.send_q: -- cgit v1.2.3