summaryrefslogtreecommitdiff
path: root/src/dhcpv6.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-05-04 13:32:08 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-05-04 16:15:50 +0300
commit4eef3f40d32a4351f65899af80c94492641a64b2 (patch)
treed5e761a0778f8b9c1369ac7c9daf325ff3bf0a4e /src/dhcpv6.c
parent89537a7c5fac80a99ca516af3b4cb410ea1d546b (diff)
downloadconnman-4eef3f40d32a4351f65899af80c94492641a64b2.tar.gz
connman-4eef3f40d32a4351f65899af80c94492641a64b2.tar.bz2
connman-4eef3f40d32a4351f65899af80c94492641a64b2.zip
dhcpv6: Refactor timer clearing
Diffstat (limited to 'src/dhcpv6.c')
-rw-r--r--src/dhcpv6.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 1d1feb29..5d09799a 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -74,6 +74,14 @@ static GHashTable *network_table;
static int dhcpv6_request(struct connman_dhcpv6 *dhcp, gboolean add_addresses);
+static void clear_timer(struct connman_dhcpv6 *dhcp)
+{
+ if (dhcp->timeout > 0) {
+ g_source_remove(dhcp->timeout);
+ dhcp->timeout = 0;
+ }
+}
+
static inline float get_random()
{
return (rand() % 200 - 100) / 1000.0;
@@ -812,10 +820,7 @@ int __connman_dhcpv6_start_renew(struct connman_network *network,
DBG("network %p dhcp %p", network, dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
g_dhcpv6_client_get_timeouts(dhcp->dhcp_client, &T1, &T2,
&last_renew, &last_rebind, &expired);
@@ -886,10 +891,7 @@ int __connman_dhcpv6_start_release(struct connman_network *network,
if (dhcp->stateless == TRUE)
return -EINVAL;
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
dhcp_client = dhcp->dhcp_client;
if (dhcp_client == NULL) {
@@ -933,10 +935,7 @@ static int dhcpv6_release(struct connman_dhcpv6 *dhcp)
{
DBG("dhcp %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
dhcpv6_free(dhcp);
@@ -1036,10 +1035,7 @@ static void advertise_cb(GDHCPClient *dhcp_client, gpointer user_data)
DBG("dhcpv6 advertise msg %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
if (g_dhcpv6_client_get_status(dhcp_client) != 0) {
if (dhcp->callback != NULL)
@@ -1063,10 +1059,7 @@ static void solicitation_cb(GDHCPClient *dhcp_client, gpointer user_data)
DBG("dhcpv6 solicitation msg %p", dhcp);
- if (dhcp->timeout > 0) {
- g_source_remove(dhcp->timeout);
- dhcp->timeout = 0;
- }
+ clear_timer(dhcp);
set_addresses(dhcp_client, dhcp);
}