Merge branch 'dbus-1.4'
[platform/upstream/dbus.git] / bus / bus.c
index 748ee90..ae2a61a 100644 (file)
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -126,6 +126,18 @@ remove_server_watch (DBusWatch  *watch,
   _dbus_loop_remove_watch (context->loop, watch);
 }
 
+static void
+toggle_server_watch (DBusWatch  *watch,
+                     void       *data)
+{
+  DBusServer *server = data;
+  BusContext *context;
+
+  context = server_get_context (server);
+
+  _dbus_loop_toggle_watch (context->loop, watch);
+}
+
 static dbus_bool_t
 add_server_timeout (DBusTimeout *timeout,
                     void        *data)
@@ -228,7 +240,7 @@ setup_server (BusContext *context,
   if (!dbus_server_set_watch_functions (server,
                                         add_server_watch,
                                         remove_server_watch,
-                                        NULL,
+                                        toggle_server_watch,
                                         server,
                                         NULL))
     {
@@ -258,6 +270,7 @@ process_config_first_time_only (BusContext       *context,
                                BusConfigParser  *parser,
                                 const DBusString *address,
                                 dbus_bool_t      systemd_activation,
+                                dbus_bool_t      write_pidfile,
                                DBusError        *error)
 {
   DBusString log_prefix;
@@ -273,6 +286,7 @@ process_config_first_time_only (BusContext       *context,
 
   retval = FALSE;
   auth_mechanisms = NULL;
+  pidfile = NULL;
 
   _dbus_init_system_log ();
 
@@ -283,7 +297,10 @@ process_config_first_time_only (BusContext       *context,
    * avoid that. But we want to check for the pid file
    * before overwriting any existing sockets, etc.
    */
-  pidfile = bus_config_parser_get_pidfile (parser);
+
+  if (write_pidfile)
+    pidfile = bus_config_parser_get_pidfile (parser);
+
   if (pidfile != NULL)
     {
       DBusString u;
@@ -392,6 +409,7 @@ process_config_first_time_only (BusContext       *context,
           if (auth_mechanisms[i] == NULL)
             goto oom;
           link = _dbus_list_get_next_link (auth_mechanisms_list, link);
+          i += 1;
         }
     }
   else
@@ -685,6 +703,7 @@ bus_context_new (const DBusString *config_file,
                  DBusPipe         *print_pid_pipe,
                  const DBusString *address,
                  dbus_bool_t      systemd_activation,
+                 dbus_bool_t      write_pidfile,
                  DBusError        *error)
 {
   BusContext *context;
@@ -738,7 +757,7 @@ bus_context_new (const DBusString *config_file,
       goto failed;
     }
 
-  if (!process_config_first_time_only (context, parser, address, systemd_activation, error))
+  if (!process_config_first_time_only (context, parser, address, systemd_activation, write_pidfile, error))
     {
       _DBUS_ASSERT_ERROR_IS_SET (error);
       goto failed;