diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2018-10-10 15:00:17 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-10-23 10:00:43 -0400 |
commit | 0f7019df1ecf905c72378dc9a3dcab625bb142b7 (patch) | |
tree | cadeb327c9a78b4cd1b7ad8537501bf3baf3ae28 /module/obmc/wsgi/apps | |
parent | 4b412ac926aaed11a9c335827d7c37d972399d0d (diff) | |
download | phosphor-rest-server-0f7019df1ecf905c72378dc9a3dcab625bb142b7.tar.gz phosphor-rest-server-0f7019df1ecf905c72378dc9a3dcab625bb142b7.zip |
Ensure websocket termination handled correctly
Currently when a websocket is terminated on the client side, the logic
in EventNotifier continues to run. This is because the WebSocketError
exceptions are detected in the properties/interface handlers where
that exception is just ignored.
This exception can not be sent back up to the main loop because
it goes through the dbus libraries which will fail when it
sees it.
Use a class variable to indicate when a websocket error has
been hit and break out of the loop. Also, remove signal handlers.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Removed good path tracing.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I068f19fd75aa03fb71d98e9ff75f596941c8622f
Diffstat (limited to 'module/obmc/wsgi/apps')
-rw-r--r-- | module/obmc/wsgi/apps/rest_dbus.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index bf7db41..a0f6e4d 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -967,22 +967,26 @@ class EventNotifier: self.wsock = wsock self.paths = filters.get("paths", []) self.interfaces = filters.get("interfaces", []) + self.signals = [] + self.socket_error = False if not self.paths: self.paths.append(None) bus = dbus.SystemBus() # Add a signal receiver for every path the client is interested in for path in self.paths: - bus.add_signal_receiver( + add_sig = bus.add_signal_receiver( self.interfaces_added_handler, dbus_interface=dbus.BUS_DAEMON_IFACE + '.ObjectManager', signal_name='InterfacesAdded', path=path) - bus.add_signal_receiver( + chg_sig = bus.add_signal_receiver( self.properties_changed_handler, dbus_interface=dbus.PROPERTIES_IFACE, signal_name='PropertiesChanged', path=path, path_keyword='path') + self.signals.append(add_sig) + self.signals.append(chg_sig) loop = gobject.MainLoop() # gobject's mainloop.run() will block the entire process, so the gevent # scheduler and hence greenlets won't execute. The while-loop below @@ -991,6 +995,11 @@ class EventNotifier: gcontext = loop.get_context() while loop is not None: try: + if self.socket_error: + for signal in self.signals: + signal.remove() + loop.quit() + break; if gcontext.pending(): gcontext.iteration() else: @@ -1011,7 +1020,8 @@ class EventNotifier: response[self.keyNames['intfMap']] = iprops try: self.wsock.send(json.dumps(response)) - except WebSocketError: + except: + self.socket_error = True return def properties_changed_handler(self, interface, new, old, **kw): @@ -1026,7 +1036,8 @@ class EventNotifier: response[self.keyNames['propMap']] = new try: self.wsock.send(json.dumps(response)) - except WebSocketError: + except: + self.socket_error = True return |