summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-04-25 16:08:25 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-05-01 22:18:39 +0900
commitfe6f94434cf968c2fb836cb0d29dfded40e468fc (patch)
tree8bd6545741b18814fa4cd36cf5437802e72f0681
parent9e6d3053c00b28a9ac9435b05e4987d9f8ce8843 (diff)
controller: fix send queue draining again
and this time add comments to explain the intention. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/controller/controller.py9
1 files changed, 9 insertions, 0 deletions
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: