Commit 5efe8e7f authored by John Palmieri's avatar John Palmieri

* dbus-connection.c (dbus_connection_send_with_reply): return TRUE

  and set pending_reply out arg to NULL is connection is disconnected
  (connection_timeout_and_complete_all_pending_calls_unlocked): New
  static method for cleaning up pending calls on disconnect
  (_dbus_connection_get_dispatch_status_unlocked): If we have pending
  calls queued timeouts on disconnect

* dbus/dbus-pending-call.ci (_dbus_pending_call_set_connection):
  Remove
parent 7628b541
2006-07-13 John (J5) Palmieri <johnp@redhat.com>
* dbus-connection.c (dbus_connection_send_with_reply): return TRUE
and set pending_reply out arg to NULL is connection is disconnected
(connection_timeout_and_complete_all_pending_calls_unlocked): New
static method for cleaning up pending calls on disconnect
(_dbus_connection_get_dispatch_status_unlocked): If we have pending
calls queued timeouts on disconnect
* dbus/dbus-pending-call.ci (_dbus_pending_call_set_connection):
Remove
2006-07-13 Carlos Garcia Campos <carlosgc@gnome.org>
* bus/activation.[ch] (bus_activation_list_services): new function to
......
......@@ -386,6 +386,8 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection,
}
}
connection->n_incoming += 1;
_dbus_connection_wakeup_mainloop (connection);
......@@ -832,7 +834,6 @@ free_pending_call_on_hash_removal (void *data)
_dbus_pending_call_set_timeout_added (pending, FALSE);
}
_dbus_pending_call_clear_connection (pending);
dbus_pending_call_unref (pending);
}
}
......@@ -2359,9 +2360,9 @@ reply_handler_timeout (void *data)
*
* @param connection the connection
* @param message the message to send
* @param pending_return return location for a #DBusPendingCall object, or #NULL
* @param pending_return return location for a #DBusPendingCall object, or #NULLif connection is disconnected
* @param timeout_milliseconds timeout in milliseconds or -1 for default
* @returns #TRUE if the message is successfully queued, #FALSE if no memory.
* @returns #FALSE if no memory, #TRUE otherwise.
*
*/
dbus_bool_t
......@@ -2380,16 +2381,28 @@ dbus_connection_send_with_reply (DBusConnection *connection,
if (pending_return)
*pending_return = NULL;
CONNECTION_LOCK (connection);
if (!_dbus_connection_get_is_connected_unlocked (connection))
{
CONNECTION_UNLOCK (connection);
*pending_return = NULL;
return TRUE;
}
pending = _dbus_pending_call_new (connection,
timeout_milliseconds,
reply_handler_timeout);
if (pending == NULL)
return FALSE;
{
CONNECTION_UNLOCK (connection);
return FALSE;
}
CONNECTION_LOCK (connection);
/* Assign a serial to the message */
serial = dbus_message_get_serial (message);
if (serial == 0)
......@@ -2468,6 +2481,33 @@ check_for_reply_unlocked (DBusConnection *connection,
return NULL;
}
static void
connection_timeout_and_complete_all_pending_calls_unlocked (DBusConnection *connection)
{
DBusHashIter iter;
_dbus_hash_iter_init (connection->pending_replies, &iter);
/* create list while we remove the iters from the hash
because we need to go over it a couple of times */
while (_dbus_hash_iter_next (&iter))
{
DBusPendingCall *pending;
pending = (DBusPendingCall *) _dbus_hash_iter_get_value (&iter);
dbus_pending_call_ref (pending);
_dbus_pending_call_queue_timeout_error (pending,
connection);
_dbus_connection_remove_timeout_unlocked (connection,
_dbus_pending_call_get_timeout (pending));
_dbus_hash_iter_remove_entry (&iter);
dbus_pending_call_unref (pending);
}
}
static void
complete_pending_call_and_unlock (DBusPendingCall *pending,
DBusMessage *message)
......@@ -3300,7 +3340,10 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection)
_DBUS_FUNCTION_NAME);
connection_forget_shared_unlocked (connection);
/* If we have pending calls queued timeouts on disconnect */
connection_timeout_and_complete_all_pending_calls_unlocked (connection);
/* We haven't sent the disconnect message already,
* and all real messages have been queued up.
*/
......@@ -3734,10 +3777,12 @@ dbus_connection_dispatch (DBusConnection *connection)
"Disconnected"))
{
_dbus_bus_check_connection_and_unref (connection);
if (connection->exit_on_disconnect)
{
CONNECTION_UNLOCK (connection);
_dbus_verbose ("Exiting on Disconnected signal\n");
CONNECTION_UNLOCK (connection);
_dbus_exit (1);
_dbus_assert_not_reached ("Call to exit() returned");
}
......
......@@ -39,8 +39,6 @@ dbus_uint32_t _dbus_pending_call_get_reply_serial (DBusPendingCall *pending)
void _dbus_pending_call_set_reply_serial (DBusPendingCall *pending,
dbus_uint32_t serial);
DBusConnection *_dbus_pending_call_get_connection (DBusPendingCall *pending);
void _dbus_pending_call_set_connection (DBusPendingCall *pending,
DBusConnection *connection);
void _dbus_pending_call_complete (DBusPendingCall *pending);
void _dbus_pending_call_set_reply (DBusPendingCall *pending,
......
......@@ -83,7 +83,7 @@ _dbus_pending_call_new (DBusConnection *connection,
DBusTimeout *timeout;
_dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
if (timeout_milliseconds == -1)
timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
......@@ -119,8 +119,11 @@ _dbus_pending_call_new (DBusConnection *connection,
pending->refcount.value = 1;
pending->connection = connection;
dbus_connection_ref (pending->connection);
pending->timeout = timeout;
_dbus_data_slot_list_init (&pending->slot_list);
return pending;
......@@ -284,34 +287,6 @@ _dbus_pending_call_get_connection (DBusPendingCall *pending)
return pending->connection;
}
/**
* Sets the connection associated with the pending call
*
* @param pending the pending_call
* @param connection the connection which is associated with the pending call
*/
void
_dbus_pending_call_set_connection (DBusPendingCall *pending,
DBusConnection *connection)
{
_dbus_assert (pending != NULL);
pending->connection = connection;
}
/**
* NULLs out the connection
*
* @param pending the pending_call
*/
void
_dbus_pending_call_clear_connection (DBusPendingCall *pending)
{
_dbus_assert (pending != NULL);
pending->connection = NULL;
}
/**
* Sets the reply message associated with the pending call to a timeout error
*
......@@ -403,12 +378,13 @@ dbus_pending_call_unref (DBusPendingCall *pending)
/* If we get here, we should be already detached
* from the connection, or never attached.
*/
_dbus_assert (pending->connection == NULL);
_dbus_assert (!pending->timeout_added);
dbus_connection_unref (pending->connection);
/* this assumes we aren't holding connection lock... */
_dbus_data_slot_list_free (&pending->slot_list);
if (pending->timeout != NULL)
_dbus_timeout_unref (pending->timeout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment