]> arthur.barton.de Git - netatalk.git/commitdiff
Possible fixes to afpstats dbus issue
authorRalph Boehme <sloowfranklin@gmail.com>
Tue, 5 Mar 2013 08:32:28 +0000 (09:32 +0100)
committerRalph Boehme <sloowfranklin@gmail.com>
Tue, 5 Mar 2013 08:32:28 +0000 (09:32 +0100)
Initialize afpstats before calling configinit in main() thus ensuring
dbus glib thread initilisation is performed as we need it.

Use private dbus connection from dbus_g_bus_get_private() which should
help with issues seen where our avahi dbus thread crashed.

etc/afpd/afpstats.c
etc/afpd/main.c

index b50dc33c7887dc62c6c340652298787669a2e659..80d3e6f5f12884caf213ee6f4e39e3d0df479d34 100644 (file)
@@ -44,6 +44,7 @@ static gpointer afpstats_thread(gpointer _data)
     DBusGConnection *bus;
     DBusGProxy *bus_proxy;
     GError *error = NULL;
+    GMainContext *ctxt;
     GMainLoop *thread_loop;
     guint request_name_result;
     sigset_t sigs;
@@ -52,11 +53,12 @@ static gpointer afpstats_thread(gpointer _data)
     sigfillset(&sigs);
     pthread_sigmask(SIG_BLOCK, &sigs, NULL);
 
-    dbus_g_object_type_install_info(AFPSTATS_TYPE_OBJECT, &dbus_glib_afpstats_obj_object_info);
+    ctxt = g_main_context_new();
+    thread_loop = g_main_loop_new(ctxt, FALSE);
 
-    thread_loop = g_main_loop_new(NULL, FALSE);
+    dbus_g_object_type_install_info(AFPSTATS_TYPE_OBJECT, &dbus_glib_afpstats_obj_object_info);
    
-    if (!(bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
+    if (!(bus = dbus_g_bus_get_private(DBUS_BUS_SYSTEM, ctxt, &error))) {
         LOG(log_error, logtype_afpd,"Couldn't connect to system bus: %s", error->message);
         return NULL;
     }
@@ -110,8 +112,10 @@ int afpstats_init(server_child_t *childs_in)
 
     childs = childs_in;
     g_type_init();
-    (void)g_log_set_default_handler(my_glib_log, NULL);
     g_thread_init(NULL);
+    dbus_g_thread_init();
+    (void)g_log_set_default_handler(my_glib_log, NULL);
+
     thread = g_thread_create(afpstats_thread, NULL, TRUE, NULL);
 
     return 0;
index 141d420cdf80fc53752c6fbc680e9029d86f84fc..cd65f7a9003358971df2d7c6566c0892519f28f7 100644 (file)
@@ -312,6 +312,11 @@ int main(int ac, char **av)
     sigaddset(&sigs, SIGCHLD);
 
     pthread_sigmask(SIG_BLOCK, &sigs, NULL);
+#ifdef HAVE_DBUS_GLIB
+    /* Run dbus AFP statics thread */
+    if (obj.options.flags & OPTION_DBUS_AFPSTATS)
+        (void)afpstats_init(server_children);
+#endif
     if (configinit(&obj) != 0) {
         LOG(log_error, logtype_afpd, "main: no servers configured");
         afp_exit(EXITERR_CONF);
@@ -327,12 +332,6 @@ int main(int ac, char **av)
     /* set limits */
     (void)setlimits();
 
-#ifdef HAVE_DBUS_GLIB
-    /* Run dbus AFP statics thread */
-    if (obj.options.flags & OPTION_DBUS_AFPSTATS)
-        (void)afpstats_init(server_children);
-#endif
-
     afp_child_t *child;
     int recon_ipc_fd;
     pid_t pid;