gthreadedresolver: fix hang on g_thread_pool_push() failure
authormuralis <murali.sound@gmail.com>
Wed, 25 May 2011 08:12:59 +0000 (13:42 +0530)
committerDan Winship <danw@gnome.org>
Tue, 31 May 2011 12:56:50 +0000 (08:56 -0400)
In resolve_sync function in gthreadedresolver.c, if g_thread_pool_push
fails due to thread creation failure, we are just simply appending the
data to the queue of work to do. After the failure, we might wait
indefinitely in g_cond_wait. In case of g_thread_pool_push failure,
propagate the error so that this function does not blocks forever in
case of failure.

https://bugzilla.gnome.org/show_bug.cgi?id=651034

gio/gthreadedresolver.c

index 8c98f476e49072bb415b45f00f038e61bc9839e1..406904844ba60868b0306083f18c881c2afac824 100644 (file)
@@ -326,8 +326,9 @@ resolve_sync (GThreadedResolver         *gtr,
     }
 
   req->cond = g_cond_new ();
-  g_thread_pool_push (gtr->thread_pool, req, NULL);
-  g_cond_wait (req->cond, req->mutex);
+  g_thread_pool_push (gtr->thread_pool, req, &req->error);
+  if (!req->error)
+    g_cond_wait (req->cond, req->mutex);
   g_mutex_unlock (req->mutex);
 
   if (req->error)