From: Simon McVittie Date: Mon, 6 Nov 2017 16:28:11 +0000 (+0000) Subject: bus_context_add_incoming_connection: factor out X-Git-Tag: dbus-1.13.0~57^2~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8359321ea12a655349a619b4b64d8565003b4442;p=thirdparty%2Fdbus.git bus_context_add_incoming_connection: factor out Reviewed-by: Philip Withnall [smcv: Fix minor conflict] Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354 --- diff --git a/bus/bus.c b/bus/bus.c index c4b71600b..b0a71f67a 100644 --- 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 diff --git a/bus/bus.h b/bus/bus.h index 27d9502d0..5492af24e 100644 --- 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);