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>
This commit is contained in:
YAMAMOTO Takashi 2013-04-25 16:08:25 +09:00 committed by FUJITA Tomonori
parent 9e6d3053c0
commit fe6f94434c

View File

@ -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: