summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
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/include/ipxe
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/include/ipxe')
-rw-r--r--src/include/ipxe/retry.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/include/ipxe/retry.h b/src/include/ipxe/retry.h
index ff26de252..d2ea27fb2 100644
--- a/src/include/ipxe/retry.h
+++ b/src/include/ipxe/retry.h
@@ -49,6 +49,12 @@ struct retry_timer {
* timeout has already exceeded @c MAX_TIMEOUT.
*/
void ( * expired ) ( struct retry_timer *timer, int over );
+ /** Reference counter
+ *
+ * If this interface is not part of a reference-counted
+ * object, this field may be NULL.
+ */
+ struct refcnt *refcnt;
};
/**
@@ -56,11 +62,14 @@ struct retry_timer {
*
* @v timer Retry timer
* @v expired Timer expired callback
+ * @v refcnt Reference counter, or NULL
*/
static inline __attribute__ (( always_inline )) void
timer_init ( struct retry_timer *timer,
- void ( * expired ) ( struct retry_timer *timer, int over ) ) {
+ void ( * expired ) ( struct retry_timer *timer, int over ),
+ struct refcnt *refcnt ) {
timer->expired = expired;
+ timer->refcnt = refcnt;
}
extern void start_timer ( struct retry_timer *timer );