From fc16bdbb7ffc31706d3d39742b9b732f2c28fa17 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Jun 2017 17:57:09 +0100 Subject: [PATCH] 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 de69a225..ab69c836 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -173,8 +173,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"); @@ -185,6 +190,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, @@ -202,7 +209,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.13.2