From 82f98103e4de1f31e2b839ca6c64a12ec2f9833a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 24 Jan 2011 17:11:52 +0000 Subject: [PATCH] Add a stub _dbus_loop_toggle_watch and call it where needed --- bus/activation.c | 12 +++++++++++- bus/bus.c | 14 +++++++++++++- bus/connection.c | 11 ++++++++++- bus/test.c | 9 ++++++++- dbus/dbus-mainloop.c | 7 +++++++ dbus/dbus-mainloop.h | 2 ++ test/test-utils.c | 27 ++++++++++++++++++++------- 7 files changed, 71 insertions(+), 11 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index a3104d3..c306a17 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1417,6 +1417,16 @@ remove_babysitter_watch (DBusWatch *watch, watch); } +static void +toggle_babysitter_watch (DBusWatch *watch, + void *data) +{ + BusPendingActivation *pending_activation = data; + + _dbus_loop_toggle_watch (bus_context_get_loop (pending_activation->activation->context), + watch); +} + static dbus_bool_t pending_activation_timed_out (void *data) { @@ -2078,7 +2088,7 @@ bus_activation_activate_service (BusActivation *activation, if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter, add_babysitter_watch, remove_babysitter_watch, - NULL, + toggle_babysitter_watch, pending_activation, NULL)) { diff --git a/bus/bus.c b/bus/bus.c index 7814928..ea1facc 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -122,6 +122,18 @@ remove_server_watch (DBusWatch *watch, _dbus_loop_remove_watch (context->loop, watch); } +static void +toggle_server_watch (DBusWatch *watch, + void *data) +{ + DBusServer *server = data; + BusContext *context; + + context = server_get_context (server); + + _dbus_loop_toggle_watch (context->loop, watch); +} + static dbus_bool_t add_server_timeout (DBusTimeout *timeout, void *data) @@ -224,7 +236,7 @@ setup_server (BusContext *context, if (!dbus_server_set_watch_functions (server, add_server_watch, remove_server_watch, - NULL, + toggle_server_watch, server, NULL)) { diff --git a/bus/connection.c b/bus/connection.c index d74b3261..5d17a2f 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -312,6 +312,15 @@ remove_connection_watch (DBusWatch *watch, _dbus_loop_remove_watch (connection_get_loop (connection), watch); } +static void +toggle_connection_watch (DBusWatch *watch, + void *data) +{ + DBusConnection *connection = data; + + _dbus_loop_toggle_watch (connection_get_loop (connection), watch); +} + static dbus_bool_t add_connection_timeout (DBusTimeout *timeout, void *data) @@ -624,7 +633,7 @@ bus_connections_setup_connection (BusConnections *connections, if (!dbus_connection_set_watch_functions (connection, add_connection_watch, remove_connection_watch, - NULL, + toggle_connection_watch, connection, NULL)) goto out; diff --git a/bus/test.c b/bus/test.c index 049fae6..671a173 100644 --- a/bus/test.c +++ b/bus/test.c @@ -54,6 +54,13 @@ remove_client_watch (DBusWatch *watch, _dbus_loop_remove_watch (client_loop, watch); } +static void +toggle_client_watch (DBusWatch *watch, + void *data) +{ + _dbus_loop_toggle_watch (client_loop, watch); +} + static dbus_bool_t add_client_timeout (DBusTimeout *timeout, void *data) @@ -120,7 +127,7 @@ bus_setup_debug_client (DBusConnection *connection) if (!dbus_connection_set_watch_functions (connection, add_client_watch, remove_client_watch, - NULL, + toggle_client_watch, connection, NULL)) goto out; diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index c30825e..61ad887 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -289,6 +289,13 @@ _dbus_loop_add_watch (DBusLoop *loop, } void +_dbus_loop_toggle_watch (DBusLoop *loop, + DBusWatch *watch) +{ + /* stub */ +} + +void _dbus_loop_remove_watch (DBusLoop *loop, DBusWatch *watch) { diff --git a/dbus/dbus-mainloop.h b/dbus/dbus-mainloop.h index a3417ad..a76cb6f 100644 --- a/dbus/dbus-mainloop.h +++ b/dbus/dbus-mainloop.h @@ -41,6 +41,8 @@ dbus_bool_t _dbus_loop_add_watch (DBusLoop *loop, DBusWatch *watch); void _dbus_loop_remove_watch (DBusLoop *loop, DBusWatch *watch); +void _dbus_loop_toggle_watch (DBusLoop *loop, + DBusWatch *watch); dbus_bool_t _dbus_loop_add_timeout (DBusLoop *loop, DBusTimeout *timeout); void _dbus_loop_remove_timeout (DBusLoop *loop, diff --git a/test/test-utils.c b/test/test-utils.c index 4fd84fe..c3c3ed3 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -26,6 +26,15 @@ remove_watch (DBusWatch *watch, _dbus_loop_remove_watch (cd->loop, watch); } +static void +toggle_watch (DBusWatch *watch, + void *data) +{ + CData *cd = data; + + _dbus_loop_toggle_watch (cd->loop, watch); +} + static dbus_bool_t add_timeout (DBusTimeout *timeout, void *data) @@ -103,15 +112,10 @@ test_connection_setup (DBusLoop *loop, if (cd == NULL) goto nomem; - /* Because dbus-mainloop.c checks dbus_timeout_get_enabled(), - * dbus_watch_get_enabled() directly, we don't have to provide - * "toggled" callbacks. - */ - if (!dbus_connection_set_watch_functions (connection, add_watch, remove_watch, - NULL, + toggle_watch, cd, cdata_free)) goto nomem; @@ -213,6 +217,15 @@ add_server_watch (DBusWatch *watch, } static void +toggle_server_watch (DBusWatch *watch, + void *data) +{ + ServerData *context = data; + + _dbus_loop_toggle_watch (context->loop, watch); +} + +static void remove_server_watch (DBusWatch *watch, void *data) { @@ -252,7 +265,7 @@ test_server_setup (DBusLoop *loop, if (!dbus_server_set_watch_functions (server, add_server_watch, remove_server_watch, - NULL, + toggle_server_watch, sd, serverdata_free)) { -- 1.7.4.1