From bd58ca29fe2be51f131d4e55f05f9fe5d55d9060 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Jun 2017 17:57:09 +0100 Subject: [PATCH 19/49] bus_context_add_incoming_connection: factor out Signed-off-by: Simon McVittie --- bus/bus.c | 11 +++++++++-- bus/bus.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bus/bus.c b/bus/bus.c index 82ba25fe..6b4dcba6 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -172,8 +172,13 @@ new_connection_callback (DBusServer *server, DBusConnection *new_connection, void *data) { - BusContext *context = data; + bus_context_add_incoming_connection (data, new_connection); +} +dbus_bool_t +bus_context_add_incoming_connection (BusContext *context, + DBusConnection *new_connection) +{ if (!bus_connections_setup_connection (context->connections, new_connection)) { _dbus_verbose ("No memory to setup new connection\n"); @@ -184,6 +189,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, @@ -201,7 +208,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 diff --git a/bus/bus.h b/bus/bus.h index c382575c..c19650bd 100644 --- a/bus/bus.h +++ b/bus/bus.h @@ -150,5 +150,7 @@ 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); #endif /* BUS_BUS_H */ -- 2.11.0