diff options
author | Grant Erickson <gerickson@nuovations.com> | 2023-12-14 18:16:52 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2023-12-15 09:52:05 +0100 |
commit | f14966462b58ff40e324cd4c20d32b8fe53109b3 (patch) | |
tree | c64d938bf511d6299b0c417070e52f65ccbd04fa | |
parent | bfd957d569900def3a82f2b2bd4114bb86d1003e (diff) | |
download | connman-f14966462b58ff40e324cd4c20d32b8fe53109b3.tar.gz |
service: Add support for 'CONNMAN_IPCONFIG_TYPE_ALL' to 'cancel_online_check'.
This adds support for passing 'CONNMAN_IPCONFIG_TYPE_ALL' to
'cancel_online_check' as the IP configuration type parameter to allow
for canceling both IPv4 and IPv6 checks in a single function call.
-rw-r--r-- | src/service.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/service.c b/src/service.c index 5ead14ac6..6f816ac7a 100644 --- a/src/service.c +++ b/src/service.c @@ -1615,6 +1615,8 @@ static guint online_check_timeout_compute_geometric(unsigned int interval) static void cancel_online_check(struct connman_service *service, enum connman_ipconfig_type type) { + bool do_ipv4 = false, do_ipv6 = false; + DBG("service %p (%s) type %d (%s) " "online_timeout_ipv4 %d online_timeout_ipv6 %d", service, connman_service_get_identifier(service), @@ -1622,20 +1624,34 @@ static void cancel_online_check(struct connman_service *service, service->online_check_state_ipv4.timeout, service->online_check_state_ipv6.timeout); + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) + do_ipv4 = true; + else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) + do_ipv6 = true; + else if (type == CONNMAN_IPCONFIG_TYPE_ALL) + do_ipv4 = do_ipv6 = true; + else + return; + /* - * First, ensure that the reachability check is cancelled in the - * WISPr module. This may fail, however, we ignore any such - * failures as we still want to cancel any outstanding check from - * this module as well. + * First, ensure that the reachability check(s) is/are cancelled + * in the WISPr module. This may fail, however, we ignore any such + * failures as we still want to cancel any outstanding check(s) + * from this module as well. */ - __connman_wispr_cancel(service, type); + + if (do_ipv4) + __connman_wispr_cancel(service, CONNMAN_IPCONFIG_TYPE_IPV4); + + if (do_ipv6) + __connman_wispr_cancel(service, CONNMAN_IPCONFIG_TYPE_IPV6); /* - * Now that the reachability check has been cancelled in the WISPr - * module, cancel any outstanding check that may be scheduled in - * this module. + * Now that the reachability check(s) has/have been cancelled in + * the WISPr module, cancel any outstanding check(s) that may be + * scheduled in this module. */ - if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && + if (do_ipv4 && service->online_check_state_ipv4.timeout) { g_source_remove(service->online_check_state_ipv4.timeout); service->online_check_state_ipv4.timeout = 0; @@ -1646,7 +1662,9 @@ static void cancel_online_check(struct connman_service *service, * now-cancelled scheduled online check. */ connman_service_unref(service); - } else if (type == CONNMAN_IPCONFIG_TYPE_IPV6 && + } + + if (do_ipv6 && service->online_check_state_ipv6.timeout) { g_source_remove(service->online_check_state_ipv6.timeout); service->online_check_state_ipv6.timeout = 0; |