Skip to content

Commit

Permalink
fix memleak when clients diconnect and we have images queued for proc…
Browse files Browse the repository at this point in the history
…essing: ensure we continue to process them until the end of queue marker, even if they end up as no-op because the window-source is cancelled, because this ensures we free the image

git-svn-id: https://xpra.org/svn/Xpra/trunk@6023 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 4, 2014
1 parent 12ab533 commit 168b186
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/xpra/server/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,13 @@ def is_closed(self):
def close(self):
log("%s.close()", self)
self.close_event.set()
self.damage_data_queue.put(None, block=False)
for window_source in self.window_sources.values():
window_source.cleanup()
self.window_sources = {}
#it is now safe to add the end of queue marker:
#(all window sources will have stopped queuing data,
# they queue data using the UI thread, so we use it too)
self.idle_add(self.damage_data_queue.put, None)
#this should be a noop since we inherit an initialized helper:
self.video_helper.cleanup()
if self.mmap:
Expand Down Expand Up @@ -1553,7 +1556,6 @@ def queue_packet(self, packet, wid, pixels, start_send_cb, end_send_cb):
self.statistics.damage_packet_qsizes.append((now, len(self.damage_packet_queue)))
self.statistics.damage_packet_qpixels.append((now, wid, sum([x[2] for x in list(self.damage_packet_queue) if x[1]==wid])))
self.damage_packet_queue.append((packet, wid, pixels, start_send_cb, end_send_cb))
#if self.protocol._write_queue.empty():
p = self.protocol
if p:
p.source_has_more()
Expand All @@ -1565,8 +1567,10 @@ def data_to_packet(self):
"""
This runs in a separate thread and calls all the function callbacks
which are added to the 'damage_data_queue'.
Must run until we hit the end of queue marker,
to ensure all the queued items get called.
"""
while not self.is_closed():
while True:
fn_and_args = self.damage_data_queue.get(True)
if fn_and_args is None:
return #empty marker
Expand Down

0 comments on commit 168b186

Please sign in to comment.