]>
Commit | Line | Data |
---|---|---|
b55c1120 MB |
1 | From 03cc20707a3e7b2d8629e84d7a766f41edb8b444 Mon Sep 17 00:00:00 2001 |
2 | From: James Westby <jw+debian@jameswestby.net> | |
3 | Date: Thu, 01 Oct 2009 14:09:54 +0000 | |
4 | Subject: Correct timeout handling | |
5 | ||
6 | The timeout handling code subtracts the elapsed time from the timeout | |
7 | each time a message is received, which drastically reduces the timeout | |
8 | in circumstances such as service activation. | |
9 | ||
10 | Correct so that the timeout is never modified, and the elapsed time | |
11 | instead subtracted where necessary. | |
12 | ||
13 | Signed-off-by: James Westby <jw+debian@jameswestby.net> | |
14 | Signed-off-by: Scott James Remnant <scott@ubuntu.com> | |
15 | --- | |
16 | diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c | |
17 | index a59b1a0..31edd61 100644 | |
18 | --- a/dbus/dbus-connection.c | |
19 | +++ b/dbus/dbus-connection.c | |
20 | @@ -2392,7 +2392,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) | |
21 | */ | |
22 | _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); | |
23 | ||
24 | - _dbus_memory_pause_based_on_timeout (timeout_milliseconds); | |
25 | + _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); | |
26 | } | |
27 | else | |
28 | { | |
29 | @@ -2400,7 +2400,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) | |
30 | _dbus_connection_do_iteration_unlocked (connection, | |
31 | DBUS_ITERATION_DO_READING | | |
32 | DBUS_ITERATION_BLOCK, | |
33 | - timeout_milliseconds); | |
34 | + timeout_milliseconds - elapsed_milliseconds); | |
35 | } | |
36 | ||
37 | goto recheck_status; | |
38 | @@ -2409,9 +2409,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) | |
39 | _dbus_verbose ("dbus_connection_send_with_reply_and_block(): clock set backward\n"); | |
40 | else if (elapsed_milliseconds < timeout_milliseconds) | |
41 | { | |
42 | - timeout_milliseconds -= elapsed_milliseconds; | |
43 | - _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds); | |
44 | - _dbus_assert (timeout_milliseconds >= 0); | |
45 | + _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds); | |
46 | ||
47 | if (status == DBUS_DISPATCH_NEED_MEMORY) | |
48 | { | |
49 | @@ -2421,7 +2419,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) | |
50 | */ | |
51 | _dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n"); | |
52 | ||
53 | - _dbus_memory_pause_based_on_timeout (timeout_milliseconds); | |
54 | + _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); | |
55 | } | |
56 | else | |
57 | { | |
58 | @@ -2429,14 +2427,14 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) | |
59 | _dbus_connection_do_iteration_unlocked (connection, | |
60 | DBUS_ITERATION_DO_READING | | |
61 | DBUS_ITERATION_BLOCK, | |
62 | - timeout_milliseconds); | |
63 | + timeout_milliseconds - elapsed_milliseconds); | |
64 | } | |
65 | ||
66 | goto recheck_status; | |
67 | } | |
68 | ||
69 | _dbus_verbose ("dbus_connection_send_with_reply_and_block(): Waited %ld milliseconds and got no reply\n", | |
70 | - (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000); | |
71 | + elapsed_milliseconds); | |
72 | ||
73 | _dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending)); | |
74 | ||
75 | -- | |
76 | cgit v0.8.2 |