From 28b37b782023065dd0da4fe86df2f4a6e5704593 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 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354 --- 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 23c22ce6..c46dc6e6 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.3