diff options
author | Havoc Pennington <hp@redhat.com> | 2003-04-11 00:03:06 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-04-11 00:03:06 +0000 |
commit | 6be547d32f018c23ba56426a0bccd08baa2cf440 (patch) | |
tree | 00edf1d2628538d66d3f5db7a998c18ffc30ce04 /bus/dispatch.c | |
parent | 7074a2469521949c706f3b9d789d7c8eb9f3ac85 (diff) |
2003-04-10 Havoc Pennington <hp@redhat.com>
* dbus/dbus-connection.c (dbus_connection_flush): don't spin on
the connection if it's disconnected
* bus/activation.c (bus_activation_service_created): use new
transaction features to roll back removal of pending activation if
we don't successfully create the service after all. Don't remove
pending activation if the function fails.
* dbus/dbus-list.c (_dbus_list_insert_before_link)
(_dbus_list_insert_after_link): new code to facilitate
services.c fixes
* dbus/dbus-hash.c (_dbus_hash_table_insert_string_preallocated):
new functionality, so we can preallocate the ability to insert
into a hash table.
* bus/connection.c (bus_transaction_add_cancel_hook): new function
allowing us to put custom hooks in a transaction to be used for
cancelling said transaction
* doc/dbus-specification.sgml: add some discussion of secondary
service owners, and disallow zero-length service names
* bus/services.c (bus_registry_acquire_service): new function,
splits out part of bus_driver_handle_acquire_service() and fixes
a bug where we didn't remove the service doing the acquiring
from the secondary queue if we failed to remove the current owner
from the front of the queue.
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r-- | bus/dispatch.c | 98 |
1 files changed, 69 insertions, 29 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c index e867674b..f6ddc76a 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -1442,6 +1442,47 @@ check_send_exit_to_service (BusContext *context, return retval; } +static dbus_bool_t +check_got_error (BusContext *context, + DBusConnection *connection, + const char *error_name) +{ + DBusMessage *message; + dbus_bool_t retval; + + retval = FALSE; + + message = pop_message_waiting_for_memory (connection); + if (message == NULL) + { + _dbus_warn ("Did not get an expected error\n"); + goto out; + } + + if (!dbus_message_get_is_error (message)) + { + _dbus_warn ("Expected an error, got %s\n", + dbus_message_get_name (message)); + goto out; + } + + if (!dbus_message_name_is (message, error_name)) + { + _dbus_warn ("Expected error %s, got %s instead\n", + error_name, + dbus_message_get_name (message)); + goto out; + } + + retval = TRUE; + + out: + if (message) + dbus_message_unref (message); + + return retval; +} + #define EXISTENT_SERVICE_NAME "org.freedesktop.DBus.TestSuiteEchoService" /* returns TRUE if the correct thing happens, @@ -1551,6 +1592,7 @@ check_existent_service_activation (BusContext *context, else { dbus_bool_t got_service_deleted; + dbus_bool_t got_error; if (!check_base_service_activated (context, connection, message, &base_service)) @@ -1570,9 +1612,22 @@ check_existent_service_activation (BusContext *context, } got_service_deleted = dbus_message_name_is (message, DBUS_MESSAGE_SERVICE_DELETED); - + got_error = dbus_message_get_is_error (message); + dbus_connection_return_message (connection, message); message = NULL; + + if (got_error) + { + if (!check_got_error (context, connection, + DBUS_ERROR_SPAWN_CHILD_EXITED)) + goto out; + + /* A service deleted should be coming along now after this error. + * We can also get the error *after* the service deleted. + */ + got_service_deleted = TRUE; + } if (got_service_deleted) { @@ -1589,34 +1644,19 @@ check_existent_service_activation (BusContext *context, if (csdd.failed) goto out; - /* Now we should get an error about the service exiting */ - block_connection_until_message_from_bus (context, connection); - - /* and process everything again */ - bus_test_run_everything (context); - - message = pop_message_waiting_for_memory (connection); - if (message == NULL) - { - _dbus_warn ("Did not get an error from the service %s exiting\n", - EXISTENT_SERVICE_NAME); - goto out; - } - - if (!dbus_message_get_is_error (message)) - { - _dbus_warn ("Expected an error due to service exiting, got %s\n", - dbus_message_get_name (message)); - goto out; - } - - if (!dbus_message_name_is (message, - DBUS_ERROR_SPAWN_CHILD_EXITED)) + /* Now we should get an error about the service exiting + * if we didn't get it before. + */ + if (!got_error) { - _dbus_warn ("Expected error %s on service exit, got %s instead\n", - DBUS_ERROR_SPAWN_CHILD_EXITED, - dbus_message_get_name (message)); - goto out; + block_connection_until_message_from_bus (context, connection); + + /* and process everything again */ + bus_test_run_everything (context); + + if (!check_got_error (context, connection, + DBUS_ERROR_SPAWN_CHILD_EXITED)) + goto out; } } else @@ -1785,7 +1825,7 @@ bus_dispatch_test (const DBusString *test_data_dir) if (!check_hello_message (context, baz)) _dbus_assert_not_reached ("hello message failed"); -#if 0 +#if 1 check2_try_iterations (context, foo, "existent_service_activation", check_existent_service_activation); #endif |