]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
bus_context_add_incoming_connection: factor out
authorSimon McVittie <smcv@collabora.com>
Mon, 6 Nov 2017 16:28:11 +0000 (16:28 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 12 Dec 2017 16:22:29 +0000 (16:22 +0000)
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Fix minor conflict]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354

bus/bus.c
bus/bus.h

index c4b71600be5ff907a60464f0bf9fd404d3f88a55..b0a71f67a865c699990a818cbf6a78439c2ce825 100644 (file)
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -176,8 +176,14 @@ new_connection_callback (DBusServer     *server,
                          DBusConnection *new_connection,
                          void           *data)
 {
-  BusContext *context = data;
+  /* If this fails it logs a warning, so we don't need to do that */
+  bus_context_add_incoming_connection (data, new_connection);
+}
 
+dbus_bool_t
+bus_context_add_incoming_connection (BusContext *context,
+                                     DBusConnection *new_connection)
+{
   /* If this fails it logs a warning, so we don't need to do that */
   if (!bus_connections_setup_connection (context->connections, new_connection))
     {
@@ -187,6 +193,8 @@ new_connection_callback (DBusServer     *server,
        * in general.
        */
       dbus_connection_close (new_connection);
+      /* on OOM, we won't have ref'd the connection so it will die. */
+      return FALSE;
     }
 
   dbus_connection_set_max_received_size (new_connection,
@@ -204,7 +212,7 @@ new_connection_callback (DBusServer     *server,
   dbus_connection_set_allow_anonymous (new_connection,
                                        context->allow_anonymous);
 
-  /* on OOM, we won't have ref'd the connection so it will die. */
+  return TRUE;
 }
 
 static void
index 27d9502d09c9199fe3576a82b3cebdaaf5d5733c..5492af24e80ef9528280441f92541f371b4c0773 100644 (file)
--- a/bus/bus.h
+++ b/bus/bus.h
@@ -150,6 +150,8 @@ void              bus_context_check_all_watches                  (BusContext
 dbus_bool_t       bus_context_setup_server                       (BusContext       *context,
                                                                   DBusServer       *server,
                                                                   DBusError        *error);
+dbus_bool_t       bus_context_add_incoming_connection            (BusContext       *context,
+                                                                  DBusConnection   *new_connection);
 
 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
 void              bus_context_quiet_log_begin                    (BusContext *context);