mirror of
https://github.com/ipxe/ipxe
synced 2025-12-29 19:38:37 +03:00
[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:
@@ -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,
|
||||
|
||||
@@ -527,7 +527,7 @@ static int dns_resolv ( struct interface *resolv,
|
||||
ref_init ( &dns->refcnt, NULL );
|
||||
intf_init ( &dns->resolv, &dns_resolv_desc, &dns->refcnt );
|
||||
intf_init ( &dns->socket, &dns_socket_desc, &dns->refcnt );
|
||||
timer_init ( &dns->timer, dns_timer_expired );
|
||||
timer_init ( &dns->timer, dns_timer_expired, &dns->refcnt );
|
||||
memcpy ( &dns->sa, sa, sizeof ( dns->sa ) );
|
||||
|
||||
/* Create query */
|
||||
|
||||
@@ -695,8 +695,10 @@ static int slam_open ( struct interface *xfer, struct uri *uri ) {
|
||||
intf_init ( &slam->xfer, &slam_xfer_desc, &slam->refcnt );
|
||||
intf_init ( &slam->socket, &slam_socket_desc, &slam->refcnt );
|
||||
intf_init ( &slam->mc_socket, &slam_mc_socket_desc, &slam->refcnt );
|
||||
timer_init ( &slam->master_timer, slam_master_timer_expired );
|
||||
timer_init ( &slam->slave_timer, slam_slave_timer_expired );
|
||||
timer_init ( &slam->master_timer, slam_master_timer_expired,
|
||||
&slam->refcnt );
|
||||
timer_init ( &slam->slave_timer, slam_slave_timer_expired,
|
||||
&slam->refcnt );
|
||||
/* Fake an invalid cached header of { 0x00, ... } */
|
||||
slam->header_len = 1;
|
||||
/* Fake parameters for initial NACK */
|
||||
|
||||
@@ -1097,7 +1097,7 @@ static int tftp_core_open ( struct interface *xfer, struct uri *uri,
|
||||
intf_init ( &tftp->xfer, &tftp_xfer_desc, &tftp->refcnt );
|
||||
intf_init ( &tftp->socket, &tftp_socket_desc, &tftp->refcnt );
|
||||
intf_init ( &tftp->mc_socket, &tftp_mc_socket_desc, &tftp->refcnt );
|
||||
timer_init ( &tftp->timer, tftp_timer_expired );
|
||||
timer_init ( &tftp->timer, tftp_timer_expired, &tftp->refcnt );
|
||||
tftp->uri = uri_get ( uri );
|
||||
tftp->blksize = TFTP_DEFAULT_BLKSIZE;
|
||||
tftp->flags = flags;
|
||||
|
||||
Reference in New Issue
Block a user