diff options
author | James Westby <jw+debian@jameswestby.net> | 2009-10-01 15:09:54 +0100 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-01-28 17:01:23 -0500 |
commit | e2aee8bdebc0f95ff626680b9882e74442c05f98 (patch) | |
tree | 41129a97d8bd6f55278710a60d1ee43c4d1e48b4 | |
parent | 6067f88afd3b09eb4173bad48eed79bead748a60 (diff) | |
download | dbus-e2aee8bdebc0f95ff626680b9882e74442c05f98.tar.gz |
Correct timeout handling
The timeout handling code subtracts the elapsed time from the timeout
each time a message is received, which drastically reduces the timeout
in circumstances such as service activation.
Correct so that the timeout is never modified, and the elapsed time
instead subtracted where necessary.
Signed-off-by: James Westby <jw+debian@jameswestby.net>
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
-rw-r--r-- | dbus/dbus-connection.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index c933d7d1..5fb234dc 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2386,7 +2386,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) */ _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); - _dbus_memory_pause_based_on_timeout (timeout_milliseconds); + _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else { @@ -2394,7 +2394,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_connection_do_iteration_unlocked (connection, DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK, - timeout_milliseconds); + timeout_milliseconds - elapsed_milliseconds); } goto recheck_status; @@ -2403,9 +2403,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_verbose ("dbus_connection_send_with_reply_and_block(): clock set backward\n"); else if (elapsed_milliseconds < timeout_milliseconds) { - timeout_milliseconds -= elapsed_milliseconds; - _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds); - _dbus_assert (timeout_milliseconds >= 0); + _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds); if (status == DBUS_DISPATCH_NEED_MEMORY) { @@ -2415,7 +2413,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) */ _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); - _dbus_memory_pause_based_on_timeout (timeout_milliseconds); + _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else { @@ -2423,14 +2421,14 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_connection_do_iteration_unlocked (connection, DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK, - timeout_milliseconds); + timeout_milliseconds - elapsed_milliseconds); } goto recheck_status; } _dbus_verbose ("dbus_connection_send_with_reply_and_block(): Waited %ld milliseconds and got no reply\n", - (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000); + elapsed_milliseconds); _dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending)); |