From e421626d86b4d1d037a0ce99c9f9efc51b69414f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 21 Jan 2011 18:24:19 +0000 Subject: bus-activation: separate the "finished" callback from the watch callback This has been marked as broken since 2003... Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33342 Reviewed-by: Thiago Macieira --- bus/activation.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'bus/activation.c') diff --git a/bus/activation.c b/bus/activation.c index 7ce463c3..d5424a7c 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1323,22 +1323,16 @@ handle_servicehelper_exit_error (int exit_code, } } -static dbus_bool_t -babysitter_watch_callback (DBusWatch *watch, - unsigned int condition, - void *data) +static void +pending_activation_finished_cb (DBusBabysitter *babysitter, + void *data) { BusPendingActivation *pending_activation = data; - dbus_bool_t retval; - DBusBabysitter *babysitter; dbus_bool_t uses_servicehelper; - babysitter = pending_activation->babysitter; - + _dbus_assert (babysitter == pending_activation->babysitter); _dbus_babysitter_ref (babysitter); - retval = dbus_watch_handle (watch, condition); - /* There are two major cases here; are we the system bus or the session? Here this * is distinguished by whether or not we use a setuid helper launcher. With the launch helper, * some process exit codes are meaningful, processed by handle_servicehelper_exit_error. @@ -1349,15 +1343,7 @@ babysitter_watch_callback (DBusWatch *watch, */ uses_servicehelper = bus_context_get_servicehelper (pending_activation->activation->context) != NULL; - /* FIXME this is broken in the same way that - * connection watches used to be; there should be - * a separate callback for status change, instead - * of doing "if we handled a watch status might - * have changed" - * - * Fixing this lets us move dbus_watch_handle - * calls into dbus-mainloop.c - */ + /* strictly speaking this is redundant with the check in dbus-spawn now */ if (_dbus_babysitter_get_child_exited (babysitter)) { DBusError error; @@ -1417,8 +1403,6 @@ babysitter_watch_callback (DBusWatch *watch, } _dbus_babysitter_unref (babysitter); - - return retval; } static dbus_bool_t @@ -1427,9 +1411,9 @@ add_babysitter_watch (DBusWatch *watch, { BusPendingActivation *pending_activation = data; - return _dbus_loop_add_watch_full ( + return _dbus_loop_add_watch ( bus_context_get_loop (pending_activation->activation->context), - watch, babysitter_watch_callback, pending_activation, NULL); + watch); } static void @@ -2119,6 +2103,10 @@ bus_activation_activate_service (BusActivation *activation, _dbus_assert (pending_activation->babysitter != NULL); + _dbus_babysitter_set_result_function (pending_activation->babysitter, + pending_activation_finished_cb, + pending_activation); + if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter, add_babysitter_watch, remove_babysitter_watch, -- cgit v1.2.1