This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository libx2goclient.

commit b6d34d01c14f4c68be30c42fa648457b85af2e45
Author: Mihai Moldovan <io...@ionic.de>
Date:   Thu Sep 17 11:59:59 2020 +0200

    src/x2goclient-network-ssh.c: let x2goclient_network_ssh_finalize () make 
more use of the mutex.
    
    While doing so, keep the mutex clear while joining the check thread.
    
    Otherwise, we'll run into a nasty deadlock:
      - main thread takes lock
      - main thread kills check thread's main loop (currently not done, TBD)
      - main thread waits for check thread termination (join)
      - check thread tries to acquire lock after main loop termination to
        continue executing/cleaning up and terminating its main function
      - both threads wait forever.
---
 src/x2goclient-network-ssh.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c
index daa0605..082ddc0 100644
--- a/src/x2goclient-network-ssh.c
+++ b/src/x2goclient-network-ssh.c
@@ -258,11 +258,20 @@ static void x2goclient_network_ssh_finalize (GObject * 
const object) {
     g_source_unref (self->check_timeout_source);
     self->check_timeout_source = NULL;
   }
-  g_mutex_unlock (&(self->check_thread_mutex));
 
   /* Let last event run out and thread terminate. */
   if (self->check_thread) {
+    /*
+     * Keep the mutex clear while joining the thread.
+     *
+     * Otherwise, the thread's main function won't continue to execute (and
+     * finish) after its main loop (correctly) terminated.
+     */
+    g_mutex_unlock (&(self->check_thread_mutex));
+
     (void) g_thread_join (self->check_thread);
+
+    g_mutex_lock (&(self->check_thread_mutex));
     self->check_thread = NULL;
   }
 
@@ -271,6 +280,7 @@ static void x2goclient_network_ssh_finalize (GObject * 
const object) {
    * method, so let's just get rid of the pointer.
    */
   self->check_thread_context = NULL;
+  g_mutex_unlock (&(self->check_thread_mutex));
 
   g_mutex_clear (&(self->check_thread_mutex));
 

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on 
/srv/git/code.x2go.org/libx2goclient.git
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
https://lists.x2go.org/listinfo/x2go-commits

Reply via email to