Skip to content

Commit

Permalink
when running from the signal handler, timeout_add may never fire, so …
Browse files Browse the repository at this point in the history
…we define an exit() method and ensure we call it (all it does is wrap gtk_main_quit_really)

git-svn-id: https://xpra.org/svn/Xpra/trunk@9340 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed May 13, 2015
1 parent 3b93480 commit 8d60868
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/xpra/client/client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ def signal_disconnect_and_quit(self, exit_code, reason):
self.exit_on_signal = True
self.idle_add(self.disconnect_and_quit, exit_code, reason)
self.idle_add(self.quit, exit_code)
self.exit()
return
#warning: this will run cleanup code from the signal handler
self.disconnect_and_quit(exit_code, reason)
self.quit(exit_code)
self.exit()
os._exit(exit_code)

def signal_cleanup(self):
#placeholder for stuff that can be cleaned up from the signal handler
Expand All @@ -194,12 +197,15 @@ def disconnect_and_quit(self, exit_code, reason):
if p is None or p._closed:
self.quit(exit_code)
return
def do_quit():
log("disconnect_and_quit: do_quit()")
def protocol_closed():
log("disconnect_and_quit: protocol_closed()")
self.quit(exit_code)
if p:
p.flush_then_close(["disconnect", reason], done_callback=do_quit)
self.timeout_add(1000, do_quit)
p.flush_then_close(["disconnect", reason], done_callback=protocol_closed)
self.timeout_add(1000, self.quit, exit_code)

def exit(self):
sys.exit()


def client_type(self):
Expand Down
14 changes: 9 additions & 5 deletions src/xpra/client/gtk_base/gtk_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def quit(self, exit_code=0):
self.exit_code = exit_code
if gtk.main_level()>0:
#if for some reason cleanup() hangs, maybe this will fire...
gobject.timeout_add(4*1000, gtk_main_quit_really)
gobject.timeout_add(4*1000, self.exit)
#try harder!:
def force_quit():
from xpra import os_util
Expand All @@ -84,18 +84,22 @@ def force_quit():
log("GTKXpraClient.quit(%s) cleanup done, main_level=%s", exit_code, gtk.main_level())
if gtk.main_level()>0:
log("GTKXpraClient.quit(%s) main loop at level %s, calling gtk quit via timeout", exit_code, gtk.main_level())
gobject.timeout_add(500, gtk_main_quit_really)
gobject.timeout_add(500, self.exit)

def exit(self):
log("GTKXpraClient.exit() calling %s", gtk_main_quit_really)
gtk_main_quit_really()

def cleanup(self):
if self.session_info:
self.session_info.destroy()
self.session_info = None
self.session_info.destroy()
if self.bug_report:
self.bug_report.destroy()
self.bug_report = None
self.bug_report.destroy()
if self.start_new_command:
self.start_new_command.destroy()
self.start_new_command = None
self.start_new_command.destroy()
UIXpraClient.cleanup(self)


Expand Down
2 changes: 2 additions & 0 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ def stop_all_sound(self):
self.stop_receiving_sound()

def signal_cleanup(self):
log("UIXpraClient.signal_cleanup()")
XpraClientBase.signal_cleanup(self)
self.stop_all_sound()
reaper_cleanup()
log("UIXpraClient.signal_cleanup() done")


def destroy_all_windows(self):
Expand Down

0 comments on commit 8d60868

Please sign in to comment.