[evolution-data-server] Factory could close due to inactivity with slow backend subprocess open



commit dd35bbabd166bfe36b758dff9ced61d4bbdd6157
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 30 19:09:37 2014 +0100

    Factory could close due to inactivity with slow backend subprocess open
    
    In case the subprocess open takes several seconds and the inactivity
    timeout was reached before the subprocess open was completely done,
    the factory could close itself due to inactivity. Keeping the factory
    alive since the invocation of the subprocess fixes this.

 libebackend/e-data-factory.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 3e2bdb2..0ef200f 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -492,9 +492,6 @@ data_factory_connections_add (EDataFactory *data_factory,
 
        connections = data_factory->priv->connections;
 
-       if (g_hash_table_size (connections) == 0)
-               e_dbus_server_hold (E_DBUS_SERVER (data_factory));
-
        array = g_hash_table_lookup (connections, name);
 
        if (array == NULL) {
@@ -546,6 +543,11 @@ data_factory_call_subprocess_backend_create_sync (EDataFactory *data_factory,
 
                g_free (object_path);
        } else {
+               g_rec_mutex_lock (&data_factory->priv->connections_lock);
+               if (g_hash_table_size (data_factory->priv->connections) == 0)
+                       e_dbus_server_release (E_DBUS_SERVER (data_factory));
+               g_rec_mutex_unlock (&data_factory->priv->connections_lock);
+
                g_return_if_fail (error != NULL);
                g_dbus_method_invocation_take_error (invocation, error);
        }
@@ -1215,6 +1217,11 @@ data_factory_spawn_subprocess_backend (EDataFactory *data_factory,
        g_object_unref (subprocess);
 
        if (error != NULL) {
+               g_rec_mutex_lock (&priv->connections_lock);
+               if (g_hash_table_size (priv->connections) == 0)
+                       e_dbus_server_release (E_DBUS_SERVER (data_factory));
+               g_rec_mutex_unlock (&priv->connections_lock);
+
                g_mutex_lock (&priv->subprocess_watched_ids_lock);
                g_hash_table_remove (priv->subprocess_watched_ids, sd->bus_name);
                g_mutex_unlock (&priv->subprocess_watched_ids_lock);
@@ -1283,6 +1290,15 @@ e_data_factory_spawn_subprocess_backend (EDataFactory *data_factory,
        GThread *thread;
        DataFactorySpawnSubprocessBackendThreadData *data;
 
+       g_return_if_fail (E_IS_DATA_FACTORY (data_factory));
+
+       /* Make sure the server will not quit due to inactivity while
+          the subprocess is opening */
+       g_rec_mutex_lock (&data_factory->priv->connections_lock);
+       if (g_hash_table_size (data_factory->priv->connections) == 0)
+               e_dbus_server_hold (E_DBUS_SERVER (data_factory));
+       g_rec_mutex_unlock (&data_factory->priv->connections_lock);
+
        data = data_factory_spawn_subprocess_backend_thread_data_new (
                data_factory, invocation, uid, extension_name, subprocess_path);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]