[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>
This commit is contained in:
Michael Brown
2010-09-03 21:28:43 +01:00
parent 25447294d5
commit 28934eef81
10 changed files with 31 additions and 14 deletions
+2 -2
View File
@@ -1425,7 +1425,7 @@ int start_dhcp ( struct interface *job, struct net_device *netdev ) {
ref_init ( &dhcp->refcnt, dhcp_free );
intf_init ( &dhcp->job, &dhcp_job_desc, &dhcp->refcnt );
intf_init ( &dhcp->xfer, &dhcp_xfer_desc, &dhcp->refcnt );
timer_init ( &dhcp->timer, dhcp_timer_expired );
timer_init ( &dhcp->timer, dhcp_timer_expired, &dhcp->refcnt );
dhcp->netdev = netdev_get ( netdev );
dhcp->local.sin_family = AF_INET;
dhcp->local.sin_port = htons ( BOOTPC_PORT );
@@ -1528,7 +1528,7 @@ int start_pxebs ( struct interface *job, struct net_device *netdev,
ref_init ( &dhcp->refcnt, dhcp_free );
intf_init ( &dhcp->job, &dhcp_job_desc, &dhcp->refcnt );
intf_init ( &dhcp->xfer, &dhcp_xfer_desc, &dhcp->refcnt );
timer_init ( &dhcp->timer, dhcp_timer_expired );
timer_init ( &dhcp->timer, dhcp_timer_expired, &dhcp->refcnt );
dhcp->netdev = netdev_get ( netdev );
dhcp->local.sin_family = AF_INET;
fetch_ipv4_setting ( netdev_settings ( netdev ), &ip_setting,