From 46f4ced1651ef7330fb67e3f76a36b6c73c0261e Mon Sep 17 00:00:00 2001 From: Victor Orlikowski Date: Fri, 25 Dec 2015 05:42:01 +0000 Subject: [PATCH] Clean up for stability patch submitted previously While continuing to run our application with the stability patch I submitted earlier, I discovered additional failure modes for some of our hardware switches were causing unexpected exceptions. This revision better handles these situations. Signed-off-by: Victor J. Orlikowski Signed-off-by: FUJITA Tomonori --- ryu/controller/controller.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index b13ba889..25b8776d 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -30,7 +30,7 @@ from ryu.lib.hub import StreamServer import traceback import random import ssl -from socket import IPPROTO_TCP, TCP_NODELAY +from socket import IPPROTO_TCP, TCP_NODELAY, timeout as SocketTimeout, error as SocketError import warnings import ryu.base.app_manager @@ -172,12 +172,11 @@ class Datapath(ofproto_protocol.ProtocolDesc): try: ret = self.socket.recv(required_len) - except: - # Hit socket timeout; decide what to do. - if self.close_requested: - pass - else: + except SocketTimeout: + if not self.close_requested: continue + except SocketError: + self.close_requested = True if (len(ret) == 0) or (self.close_requested): self.socket.close()