summaryrefslogtreecommitdiff
path: root/gdhcp
diff options
context:
space:
mode:
authorGrant Erickson <marathon96@gmail.com>2011-06-01 21:16:13 -0700
committerSamuel Ortiz <sameo@linux.intel.com>2011-06-14 11:26:27 +0200
commiteb16a6becb8ab1dd4be3696ab446ab91830f6fc5 (patch)
tree00d8690bf0746d2e2302115d06bb9dc06622b91c /gdhcp
parent6996a25658098d3a2133b0388fd6c4c1de61bf4d (diff)
downloadconnman-eb16a6becb8ab1dd4be3696ab446ab91830f6fc5.tar.gz
connman-eb16a6becb8ab1dd4be3696ab446ab91830f6fc5.tar.bz2
connman-eb16a6becb8ab1dd4be3696ab446ab91830f6fc5.zip
dhcp: Cancel old renewal timeout prior to adding a new one
Given the following reproduction steps: 1) Set up an access point with a Class B IP address, say 10.2.40.254. 2) Set up the access point to provide DHCP leases over a range 10.2.40.2 through 10.2.40.253. 3) Set up a short lease renewal period of 5-10 minutes. 4) Allow the device to associate, connect and receive an IP address. 5) Midway through the lease interval, change the access point to a different IP address, say, 10.2.41.254. 6) Change the access point to issue DHCP leases over a new range, 10.2.41.2 through 10.2.41.253. 7) Watch as the access point resets, the connection is lost, the connection is regained and as connman tries to get a new DHCP lease. Prior to commit 39825846, connman could receive a new but different DHCP lease but connman would not program the confirmed lease to the interface. However, following that commit, it now programs the new, changed DHCP lease to the interface but still believes the old lease is valid and attempts to keep servicing the old renewal timeout for the prior but now stale lease. This patch cancels any existing, pending DHCP lease renewal timeout following a DHCP lease configuration change.
Diffstat (limited to 'gdhcp')
-rw-r--r--gdhcp/client.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 4a873bf9..0cf39cd7 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -944,6 +944,9 @@ static gboolean start_renew_timeout(gpointer user_data)
else {
send_renew(dhcp_client);
+ if (dhcp_client->timeout > 0)
+ g_source_remove(dhcp_client->timeout);
+
dhcp_client->timeout =
g_timeout_add_seconds_full(G_PRIORITY_HIGH,
dhcp_client->lease_seconds >> 1,
@@ -961,6 +964,9 @@ static void start_bound(GDHCPClient *dhcp_client)
dhcp_client->state = BOUND;
+ if (dhcp_client->timeout > 0)
+ g_source_remove(dhcp_client->timeout);
+
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
dhcp_client->lease_seconds >> 1,
start_renew_timeout, dhcp_client,