From 51781f541094a4936d47119cd62682e0431c41e9 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 10 Apr 2003 05:12:19 +0000 Subject: 2003-04-10 Havoc Pennington * bus/dispatch.c: lots of fixes * dbus/dbus-mainloop.c (_dbus_loop_dispatch): export (_dbus_loop_iterate): remove old "quit if no callbacks" code, that was crack, broke the test service. * dbus/dbus-transport.c (_dbus_transport_open): fix error handling to avoid piling up errors if we get a failure on the first address. * dbus/dbus-internals.c (_dbus_real_assert_not_reached): include pid in assertion failures. * dbus/dbus-mainloop.c (_dbus_loop_iterate): use static arrays up to some fixed size of file descriptor array. Don't return TRUE anytime a timeout exists, that led to lots of busy loop silliness in the tests. --- dbus/dbus-transport.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'dbus/dbus-transport.c') diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index d074480a..e715bd1a 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -213,6 +213,8 @@ _dbus_transport_open (const char *address, { DBusTransport *transport; DBusAddressEntry **entries; + DBusError tmp_error; + DBusError first_error; int len, i; const char *address_problem_type; const char *address_problem_field; @@ -223,15 +225,21 @@ _dbus_transport_open (const char *address, if (!dbus_parse_address (address, &entries, &len, error)) return NULL; + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + transport = NULL; address_problem_type = NULL; address_problem_field = NULL; address_problem_other = NULL; - + + dbus_error_init (&tmp_error); + dbus_error_init (&first_error); for (i = 0; i < len; i++) { - const char *method = dbus_address_entry_get_method (entries[i]); + const char *method; + method = dbus_address_entry_get_method (entries[i]); + if (strcmp (method, "unix") == 0) { const char *path = dbus_address_entry_get_value (entries[i], "path"); @@ -250,7 +258,7 @@ _dbus_transport_open (const char *address, goto bad_address; } - transport = _dbus_transport_new_for_domain_socket (path, error); + transport = _dbus_transport_new_for_domain_socket (path, &tmp_error); } else if (strcmp (method, "tcp") == 0) { @@ -277,7 +285,7 @@ _dbus_transport_open (const char *address, goto bad_address; } - transport = _dbus_transport_new_for_tcp_socket (host, lport, error); + transport = _dbus_transport_new_for_tcp_socket (host, lport, &tmp_error); } #ifdef DBUS_BUILD_TESTS else if (strcmp (method, "debug") == 0) @@ -290,8 +298,8 @@ _dbus_transport_open (const char *address, address_problem_field = "name"; goto bad_address; } - - transport = _dbus_transport_debug_client_new (name, error); + + transport = _dbus_transport_debug_client_new (name, &tmp_error); } else if (strcmp (method, "debug-pipe") == 0) { @@ -303,8 +311,8 @@ _dbus_transport_open (const char *address, address_problem_field = "name"; goto bad_address; } - - transport = _dbus_transport_debug_pipe_new (name, error); + + transport = _dbus_transport_debug_pipe_new (name, &tmp_error); } #endif else @@ -314,9 +322,29 @@ _dbus_transport_open (const char *address, } if (transport) - break; + break; + + _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); + + if (i == 0) + dbus_move_error (&tmp_error, &first_error); + else + dbus_error_free (&tmp_error); } + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); + + if (transport == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (&first_error); + dbus_move_error (&first_error, error); + } + else + { + dbus_error_free (&first_error); + } + dbus_address_entries_free (entries); return transport; @@ -771,6 +799,8 @@ dbus_bool_t _dbus_transport_queue_messages (DBusTransport *transport) { DBusDispatchStatus status; + + _dbus_verbose ("_dbus_transport_queue_messages()\n"); /* Queue any messages */ while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS) -- cgit