mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-02 00:17:57 +02:00
* bus/test-main.c (main): Initialize threading during tests
* dbus/dbus-connection.c (_dbus_connection_new_for_transport): Unlock connection on error (generate_local_error_message): static method for generating an error message when we don't have a message to reply to (_dbus_connection_block_pending_call): Send a disconnect error instead of just a timeout (NULL) when the bus gets disconnected while blocking for a reply.
This commit is contained in:
parent
b4d571bba3
commit
f61a63cefb
3 changed files with 72 additions and 10 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
2006-09-08 John (J5) Palmieri <johnp@redhat.com>
|
||||
|
||||
* bus/test-main.c (main): Initialize threading during tests
|
||||
|
||||
* dbus/dbus-connection.c (_dbus_connection_new_for_transport):
|
||||
Unlock connection on error
|
||||
(generate_local_error_message): static method for generating
|
||||
an error message when we don't have a message to reply to
|
||||
(_dbus_connection_block_pending_call): Send a disconnect error
|
||||
instead of just a timeout (NULL) when the bus gets disconnected
|
||||
while blocking for a reply.
|
||||
|
||||
|
||||
2006-09-08 John (J5) Palmieri <johnp@redhat.com>
|
||||
|
||||
* dbus/dbus-connection.c (dbus_connection_dispatch): Properly remove
|
||||
|
|
|
|||
|
|
@ -93,11 +93,8 @@ main (int argc, char **argv)
|
|||
|
||||
_dbus_string_init_const (&test_data_dir, dir);
|
||||
|
||||
#if 0
|
||||
/* FIXME 1.0 this is disabled because of thread bugs that need fixing... */
|
||||
if (!_dbus_threads_init_debug ())
|
||||
die ("initializing debug threads");
|
||||
#endif
|
||||
|
||||
test_pre_hook ();
|
||||
printf ("%s: Running expire list test\n", argv[0]);
|
||||
|
|
|
|||
|
|
@ -1190,7 +1190,11 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
|
|||
CONNECTION_LOCK (connection);
|
||||
|
||||
if (!_dbus_transport_set_connection (transport, connection))
|
||||
goto error;
|
||||
{
|
||||
CONNECTION_UNLOCK (connection);
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
_dbus_transport_ref (transport);
|
||||
|
||||
|
|
@ -2632,6 +2636,52 @@ _dbus_memory_pause_based_on_timeout (int timeout_milliseconds)
|
|||
_dbus_sleep_milliseconds (1000);
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
generate_local_error_message (dbus_uint32_t serial,
|
||||
char *error_name,
|
||||
char *error_msg)
|
||||
{
|
||||
DBusMessage *message;
|
||||
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
|
||||
if (!message)
|
||||
goto out;
|
||||
|
||||
if (!dbus_message_set_error_name (message, error_name))
|
||||
{
|
||||
dbus_message_unref (message);
|
||||
message = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dbus_message_set_no_reply (message, TRUE);
|
||||
|
||||
if (!dbus_message_set_reply_serial (message,
|
||||
serial))
|
||||
{
|
||||
dbus_message_unref (message);
|
||||
message = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (error_msg != NULL)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
|
||||
dbus_message_iter_init_append (message, &iter);
|
||||
if (!dbus_message_iter_append_basic (&iter,
|
||||
DBUS_TYPE_STRING,
|
||||
&error_msg))
|
||||
{
|
||||
dbus_message_unref (message);
|
||||
message = NULL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks until a pending call times out or gets a reply.
|
||||
*
|
||||
|
|
@ -2731,12 +2781,14 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending)
|
|||
|
||||
if (!_dbus_connection_get_is_connected_unlocked (connection))
|
||||
{
|
||||
/* FIXME 1.0 send a "DBUS_ERROR_DISCONNECTED" instead, just to help
|
||||
* programmers understand what went wrong since the timeout is
|
||||
* confusing
|
||||
*/
|
||||
|
||||
complete_pending_call_and_unlock (connection, pending, NULL);
|
||||
DBusMessage *error_msg;
|
||||
|
||||
error_msg = generate_local_error_message (client_serial,
|
||||
DBUS_ERROR_DISCONNECTED,
|
||||
"Connection was dissconnected before a reply was recived");
|
||||
|
||||
/* on OOM error_msg is set to NULL */
|
||||
complete_pending_call_and_unlock (connection, pending, error_msg);
|
||||
dbus_pending_call_unref (pending);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue