[tor-commits] [flashproxy/master] Start the registration thread only after background forking.

dcf at torproject.org dcf at torproject.org
Mon Sep 24 06:26:36 UTC 2012


commit e4bccbfe468dc32302bdbdab91ad7ddee79af151
Author: David Fifield <david at bamsoftware.com>
Date:   Sun Sep 23 23:03:57 2012 -0700

    Start the registration thread only after background forking.
    
    I don't know the exact cause, but something was causing the registration
    thread to hand at the subprocess.Popen call, but only when the program
    was run with the --daemon option, which causes it to fork at startup.
    Starting the thread after the fork seems to make the problem go away. It
    might be this bugs I found while searching:
    	http://bugs.python.org/issue13817
---
 flashproxy-client |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/flashproxy-client b/flashproxy-client
index 746f5eb..efdfafe 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -980,12 +980,6 @@ if __name__ == "__main__":
     # Locals not yet linked with a remote. This is a subset of remotes.
     unlinked_locals = []
 
-    if options.register:
-        registration_thread = threading.Thread(target=registration_thread_func, name="register")
-        registration_thread.daemon = True
-        registration_thread.start()
-        register()
-
     if options.daemonize:
         log(u"Daemonizing.")
         pid = os.fork()
@@ -995,6 +989,13 @@ if __name__ == "__main__":
                 print >> f, pid
                 f.close()
             sys.exit(0)
+
+    if options.register:
+        registration_thread = threading.Thread(target=registration_thread_func, name="register")
+        registration_thread.daemon = True
+        registration_thread.start()
+        register()
+
     try:
         main()
     except Exception:





More information about the tor-commits mailing list