|
@@ -36,20 +36,11 @@
|
36
|
36
|
*
|
37
|
37
|
*/
|
38
|
38
|
|
39
|
|
-/** Default timeout value */
|
40
|
|
-#define MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
|
41
|
|
-
|
42
|
|
-/** Limit after which the timeout will be deemed permanent */
|
43
|
|
-#define MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
|
44
|
|
-
|
45
|
39
|
/* The theoretical minimum that the algorithm in stop_timer() can
|
46
|
40
|
* adjust the timeout back down to is seven ticks, so set the minimum
|
47
|
41
|
* timeout to at least that value for the sake of consistency.
|
48
|
42
|
*/
|
49
|
|
-#if MIN_TIMEOUT < 7
|
50
|
|
-#undef MIN_TIMEOUT
|
51
|
43
|
#define MIN_TIMEOUT 7
|
52
|
|
-#endif
|
53
|
44
|
|
54
|
45
|
/** List of running timers */
|
55
|
46
|
static LIST_HEAD ( timers );
|
|
@@ -67,8 +58,17 @@ void start_timer ( struct retry_timer *timer ) {
|
67
|
58
|
if ( ! timer_running ( timer ) )
|
68
|
59
|
list_add ( &timer->list, &timers );
|
69
|
60
|
timer->start = currticks();
|
70
|
|
- if ( timer->timeout < MIN_TIMEOUT )
|
71
|
|
- timer->timeout = MIN_TIMEOUT;
|
|
61
|
+
|
|
62
|
+ /* 0 means "use default timeout" */
|
|
63
|
+ if ( timer->min_timeout == 0 )
|
|
64
|
+ timer->min_timeout = DEFAULT_MIN_TIMEOUT;
|
|
65
|
+ /* We must never be less than MIN_TIMEOUT under any circumstances */
|
|
66
|
+ if ( timer->min_timeout < MIN_TIMEOUT )
|
|
67
|
+ timer->min_timeout = MIN_TIMEOUT;
|
|
68
|
+ /* Honor user-specified minimum timeout */
|
|
69
|
+ if ( timer->timeout < timer->min_timeout )
|
|
70
|
+ timer->timeout = timer->min_timeout;
|
|
71
|
+
|
72
|
72
|
DBG2 ( "Timer %p started at time %ld (expires at %ld)\n",
|
73
|
73
|
timer, timer->start, ( timer->start + timer->timeout ) );
|
74
|
74
|
}
|
|
@@ -150,8 +150,10 @@ static void timer_expired ( struct retry_timer *timer ) {
|
150
|
150
|
|
151
|
151
|
/* Back off the timeout value */
|
152
|
152
|
timer->timeout <<= 1;
|
153
|
|
- if ( ( fail = ( timer->timeout > MAX_TIMEOUT ) ) )
|
154
|
|
- timer->timeout = MAX_TIMEOUT;
|
|
153
|
+ if ( timer->max_timeout == 0 ) /* 0 means "use default timeout" */
|
|
154
|
+ timer->max_timeout = DEFAULT_MAX_TIMEOUT;
|
|
155
|
+ if ( ( fail = ( timer->timeout > timer->max_timeout ) ) )
|
|
156
|
+ timer->timeout = timer->max_timeout;
|
155
|
157
|
DBG ( "Timer %p timeout backed off to %ld\n",
|
156
|
158
|
timer, timer->timeout );
|
157
|
159
|
|