From 28934eef81b3c7a494b12cb87804098041d64659 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 2 Sep 2010 03:34:04 +0100 Subject: [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 --- src/include/ipxe/retry.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/include') 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 ); -- cgit v1.2.3-55-g7522