summaryrefslogtreecommitdiffstats
path: root/src/net/retry.c
diff options
context:
space:
mode:
authorMichael Brown2010-09-02 04:34:04 +0200
committerMichael Brown2010-09-03 22:28:43 +0200
commit28934eef81b3c7a494b12cb87804098041d64659 (patch)
treeda46f478f9977bca4c06f5e71dc37a0066948237 /src/net/retry.c
parent[process] Add process_running() (diff)
downloadipxe-28934eef81b3c7a494b12cb87804098041d64659.tar.gz
ipxe-28934eef81b3c7a494b12cb87804098041d64659.tar.xz
ipxe-28934eef81b3c7a494b12cb87804098041d64659.zip
[retry] Hold reference while timer is running and during expiry callback
Guarantee that a retry timer cannot go out of scope while the timer is running, and provide a guarantee to the expiry callback that the timer will remain in scope during the entire callback (similar to the guarantee provided to interface methods). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/retry.c')
-rw-r--r--src/net/retry.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net/retry.c b/src/net/retry.c
index 5eefa3d4..b65bb57e 100644
--- a/src/net/retry.c
+++ b/src/net/retry.c
@@ -57,8 +57,10 @@ static LIST_HEAD ( timers );
* be stopped and the timer's callback function will be called.
*/
void start_timer ( struct retry_timer *timer ) {
- if ( ! timer->running )
+ if ( ! timer->running ) {
list_add ( &timer->list, &timers );
+ ref_get ( timer->refcnt );
+ }
timer->start = currticks();
timer->running = 1;
@@ -136,6 +138,8 @@ void stop_timer ( struct retry_timer *timer ) {
timer, timer->timeout );
}
}
+
+ ref_put ( timer->refcnt );
}
/**
@@ -164,7 +168,9 @@ static void timer_expired ( struct retry_timer *timer ) {
timer, timer->timeout );
/* Call expiry callback */
- timer->expired ( timer, fail );
+ timer->expired ( timer, fail );
+
+ ref_put ( timer->refcnt );
}
/**