diff options
author | yuta-hamada <yuta.hamada.z02@gimal.com> | 2013-11-28 14:30:01 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-11-29 09:23:37 +0900 |
commit | e8962c296edc52b4308394e52a1f381adb5603d4 (patch) | |
tree | 0c948ca51d7bff164375790d555a107f3c6a2533 | |
parent | 03ac8742f4a1628c341bb753b265915734772fbb (diff) |
rpc: If the socket is closed by peer, endpoint stop the serve.
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 <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/rpc.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ryu/lib/rpc.py b/ryu/lib/rpc.py index 57a35bab..d06180e6 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 |