aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/udp
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-09-02 03:34:04 +0100
committerMichael Brown <mcb30@ipxe.org>2010-09-03 21:28:43 +0100
commit28934eef81b3c7a494b12cb87804098041d64659 (patch)
treeda46f478f9977bca4c06f5e71dc37a0066948237 /src/net/udp
parent25447294d551bb93f63dd7e43e19b65e7c89e4db (diff)
downloadipxe-28934eef81b3c7a494b12cb87804098041d64659.tar.gz
[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/udp')
-rw-r--r--src/net/udp/dhcp.c4
-rw-r--r--src/net/udp/dns.c2
-rw-r--r--src/net/udp/slam.c6
-rw-r--r--src/net/udp/tftp.c2
4 files changed, 8 insertions, 6 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index 77d46545..1169abaa 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -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,
diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c
index 8283e6fb..ddbccc32 100644
--- a/src/net/udp/dns.c
+++ b/src/net/udp/dns.c
@@ -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 */
diff --git a/src/net/udp/slam.c b/src/net/udp/slam.c
index 026bc179..0de138cd 100644
--- a/src/net/udp/slam.c
+++ b/src/net/udp/slam.c
@@ -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 */
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c
index e8223c99..777632ef 100644
--- a/src/net/udp/tftp.c
+++ b/src/net/udp/tftp.c
@@ -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;