diff options
author | Jason Kölker <jason@koelker.net> | 2015-08-14 19:29:14 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-18 00:11:04 +0900 |
commit | 2119e6c7873a31214979823ee7c24f77ba99d7e7 (patch) | |
tree | be2d002b5cf344252975f75f030eaf449b020f39 | |
parent | d71d84fe0879df7208623ecdcb5e86cdb46c45f5 (diff) |
Handle disconnection during discover_system_id
Signed-off-by: Jason Kölker <jason@koelker.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/ovsdb/client.py | 6 | ||||
-rw-r--r-- | ryu/services/protocols/ovsdb/manager.py | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/ryu/services/protocols/ovsdb/client.py b/ryu/services/protocols/ovsdb/client.py index 175936ca..64a8bfcb 100644 --- a/ryu/services/protocols/ovsdb/client.py +++ b/ryu/services/protocols/ovsdb/client.py @@ -97,7 +97,7 @@ def discover_schemas(connection): def discover_system_id(idl): system_id = None - while system_id is None: + while system_id is None and idl._session.is_connected(): idl.run() openvswitch = idl.tables['Open_vSwitch'].rows @@ -211,6 +211,10 @@ class RemoteOvsdb(app_manager.RyuApp): idl = Idl(session, schemas[0]) system_id = discover_system_id(idl) + + if not system_id: + return None + name = cls.instance_name(system_id) ovs_stream.name = name connection.name = name diff --git a/ryu/services/protocols/ovsdb/manager.py b/ryu/services/protocols/ovsdb/manager.py index b34fb7d3..4081eea1 100644 --- a/ryu/services/protocols/ovsdb/manager.py +++ b/ryu/services/protocols/ovsdb/manager.py @@ -91,6 +91,10 @@ class OVSDB(app_manager.RyuApp): ev = event.EventNewOVSDBConnection(app.system_id) self.send_event_to_observers(ev) + else: + sock.shutdown(socket.SHUT_RDWR) + sock.close() + def start(self): server = hub.listen((self._address, self._port)) key = self.CONF.ovsdb.mngr_privkey or self.CONF.ctl_privkey |