Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* simplify + generalize protocol cleanup callbacks
* move clipboard cleanup to this callback

git-svn-id: https://xpra.org/svn/Xpra/trunk@18651 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 1, 2018
1 parent 47dacde commit f573901
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/xpra/server/mixins/clipboard_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def cleanup(self):
self._clipboard_helper = None
ch.cleanup()

def cleanup_protocol(self, proto):
ch = self._clipboard_helper
if ch and self._clipboard_client and self._clipboard_client.protocol==proto:
self._clipboard_client = None
ch.client_reset()


def get_info(self, _proto):
if self._clipboard_helper is None:
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/server/mixins/stub_server_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ def get_info(self, _proto):

def init_packet_handlers(self):
pass

def cleanup_protocol(self, protocol):
pass
19 changes: 2 additions & 17 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,6 @@ def init_sockets(self, sockets):
log.warn(" disabling printer forwarding")
self.file_transfer.printing = False

def force_disconnect(self, proto):
self.cleanup_protocol(proto)
ServerCore.force_disconnect(self, proto)

def disconnect_protocol(self, protocol, reason, *extra):
ServerCore.disconnect_protocol(self, protocol, reason, *extra)
self.cleanup_protocol(protocol)

def cleanup_protocol(self, protocol):
netlog("cleanup_protocol(%s)", protocol)
#this ensures that from now on we ignore any incoming packets coming
Expand All @@ -813,6 +805,8 @@ def cleanup_protocol(self, protocol):
del self._server_sources[protocol]
except:
pass
for c in ServerBase.__bases__:
c.cleanup_protocol(self, protocol)
return source

def cleanup_source(self, source):
Expand Down Expand Up @@ -871,15 +865,6 @@ def _disconnect_proto_info(self, proto):
return " %s" % proto
return ""

def _process_connection_lost(self, proto, packet):
ServerCore._process_connection_lost(self, proto, packet)
ch = self._clipboard_helper
if ch and self._clipboard_client and self._clipboard_client.protocol==proto:
self._clipboard_client = None
ch.client_reset()
self.cleanup_protocol(proto)


######################################################################
# packets:
def init_packet_handlers(self):
Expand Down
5 changes: 5 additions & 0 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ def send_disconnect(self, proto, *reasons):

def force_disconnect(self, proto):
netlog("force_disconnect(%s)", proto)
self.cleanup_protocol(proto)
self.cancel_verify_connection_accepted(proto)
self.cancel_upgrade_to_rfb_timer(proto)
proto.close()
Expand All @@ -1227,7 +1228,10 @@ def disconnect_protocol(self, protocol, *reasons):
self.cancel_verify_connection_accepted(protocol)
self.cancel_upgrade_to_rfb_timer(protocol)
protocol.send_disconnect(reasons)
self.cleanup_protocol(self, protocol)

def cleanup_protocol(self, proto):
pass

def _process_disconnect(self, proto, packet):
info = bytestostr(packet[1])
Expand Down Expand Up @@ -1257,6 +1261,7 @@ def _process_connection_lost(self, proto, packet):
uuid = getattr(proto, "uuid", None)
if uuid and uuid in self._udp_protocols:
del self._udp_protocols[uuid]
self.cleanup_protocol(proto)

def _process_gibberish(self, proto, packet):
(_, message, data) = packet
Expand Down

0 comments on commit f573901

Please sign in to comment.