From: yuta-hamada <[email protected]>

If client does socket.close() the serve will be non-wait looping.
So must stop the serve of endpoint that received 0 byte packet.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/lib/rpc.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ryu/lib/rpc.py b/ryu/lib/rpc.py
index 57a35ba..d06180e 100644
--- a/ryu/lib/rpc.py
+++ b/ryu/lib/rpc.py
@@ -115,6 +115,7 @@ class EndPoint(object):
         self._notifications = deque()
         self._responses = {}
         self._incoming = 0  # number of incoming messages in our queues
+        self.closed_by_peer = False
 
     def selectable(self):
         rlist = [self._sock]
@@ -142,7 +143,7 @@ class EndPoint(object):
         select.select(rlist, wlist, rlist + wlist)
 
     def serve(self):
-        while True:
+        while not self.closed_by_peer:
             self.block()
             self.process()
 
@@ -182,6 +183,9 @@ class EndPoint(object):
             except IOError:
                 packet = None
             if not packet:
+                if packet is not None:
+                    # socket closed by peer
+                    self.closed_by_peer = True
                 break
             self._encoder.get_and_dispatch_messages(packet, self._table)
         return self._incoming > 0
-- 
1.8.3.1


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to