gio: Prevent hang when finalizing GThreadedSocketService
authorRoss Lagerwall <rosslagerwall@gmail.com>
Tue, 28 Oct 2014 21:16:50 +0000 (21:16 +0000)
committerDan Winship <danw@gnome.org>
Sun, 23 Nov 2014 17:02:38 +0000 (12:02 -0500)
commit9a6e01ea5bde908e2bcce4dc66d89483e84fd837
tree02d4a9584b4a14403f97fdffbe3c75f23657765d
parent91802bbf2bfd336aec640c9412f955b1df8f80ae
gio: Prevent hang when finalizing GThreadedSocketService

If all users of a GThreadedSocketService release their references to the
service while a connection thread is running, the thread function will
release the last reference to the service which causes the finalize to
deadlock waiting for all threads to finish (because it's called from the
thread function).

To fix this, don't wait for all threads to finish in the service's
finalize method.  Since the threads hold a reference to the service,
finalize should only be called when all threads are finished running (or
have unrefed the service and are about to finish).

https://bugzilla.gnome.org/show_bug.cgi?id=712570
gio/gthreadedsocketservice.c