GTlsInteraction: Fix incorrect locking of mutex
authorStef Walter <stefw@gnome.org>
Thu, 28 Jun 2012 12:41:39 +0000 (14:41 +0200)
committerStef Walter <stefw@gnome.org>
Thu, 28 Jun 2012 12:43:12 +0000 (14:43 +0200)
 * Fix incorrect locking of mutex in g_tls_interaction_invoke_ask_password()

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

gio/gtlsinteraction.c

index 41574b7cc8e1ff2f98f875165c1c1021845027c6..e921b815d4561f2a11b4c4b527b7ddf2e8403604 100644 (file)
@@ -321,6 +321,7 @@ g_tls_interaction_invoke_ask_password (GTlsInteraction    *interaction,
   GTlsInteractionResult result;
   InvokeClosure *closure;
   GTlsInteractionClass *klass;
+  gboolean complete;
 
   g_return_val_if_fail (G_IS_TLS_INTERACTION (interaction), G_TLS_INTERACTION_UNHANDLED);
   g_return_val_if_fail (G_IS_TLS_PASSWORD (password), G_TLS_INTERACTION_UNHANDLED);
@@ -348,12 +349,16 @@ g_tls_interaction_invoke_ask_password (GTlsInteraction    *interaction,
        */
       if (g_main_context_acquire (interaction->priv->context))
         {
-          while (!closure->complete)
+          for (;;)
             {
+              g_mutex_lock (&closure->mutex);
+              complete = closure->complete;
               g_mutex_unlock (&closure->mutex);
+              if (complete)
+                break;
               g_main_context_iteration (interaction->priv->context, TRUE);
-              g_mutex_lock (&closure->mutex);
             }
+
           g_main_context_release (interaction->priv->context);
 
           if (closure->error)