ldap: Avoid a race during finalize.
authorMatthew Barnes <mbarnes@redhat.com>
Fri, 8 Jun 2012 15:47:53 +0000 (11:47 -0400)
committerMatthew Barnes <mbarnes@redhat.com>
Fri, 8 Jun 2012 15:50:07 +0000 (11:50 -0400)
Remove the poll timeout before unbinding the LDAP to avoid a race.

addressbook/backends/ldap/e-book-backend-ldap.c

index 6085a27..d3d2ab8 100644 (file)
@@ -5470,14 +5470,15 @@ e_book_backend_ldap_finalize (GObject *object)
        g_static_rec_mutex_unlock (&priv->op_hash_mutex);
        g_static_rec_mutex_free (&priv->op_hash_mutex);
 
+       /* Remove the timeout before unbinding to avoid a race. */
+       if (priv->poll_timeout > 0)
+               g_source_remove (priv->poll_timeout);
+
        g_static_rec_mutex_lock (&eds_ldap_handler_lock);
        if (priv->ldap)
                ldap_unbind (priv->ldap);
        g_static_rec_mutex_unlock (&eds_ldap_handler_lock);
 
-       if (priv->poll_timeout > 0)
-               g_source_remove (priv->poll_timeout);
-
        g_slist_foreach (priv->supported_fields, (GFunc) g_free, NULL);
        g_slist_free (priv->supported_fields);