diff mbox series

[17/17] service: Leverage '__connman_wispr_cancel'.

Message ID 20231116010259.628527-18-gerickson@nuovations.com (mailing list archive)
State Superseded
Headers show
Series Address Redundant IPv4 Reachability Checks | expand

Commit Message

Grant Erickson Nov. 16, 2023, 1:02 a.m. UTC
This leverages the newly-introduced '__connman_wispr_cancel' in
'cancel_online_check' to ensure that a pending or in-flight WISPr
portal detection request or an "online" HTTP-based Internet reachability
check is canceled not only in the service module but in the WISPr module
as well.

This prevents two concurrent, outstanding, and redundant IPv4 WISPr
requests from being in-flight when 'EnableOnlineCheck' is asserted.

Prior to this change, this redundancy was set in motion by:

    1. The two back-to-back IPv4 probes get triggered by both of the
       following paths:

       a. Triggered from 'default_changed' and 'start_wispr_if_connected'.
          This is the newer path, chronologically, in the code base.

       b. Triggered from 'service_ip_bound', 'address_updated', and
          'start_online_check'. This is the older path, chronologically,
          in the code base.

    2. With the following commits addressed:

        a. 812e171 ("Close three '__connman_wisp_start' failure closure
           holes.")

            * With this fix alone, at minimum, the first probe above (1)
              would have resulted, eventually in a failure closure with
              'complete_online_check'.

        b. 5f95851 ("wispr: Avoid 'connman_proxy_lookup' call for UNKNOWN
           proxy method.") fixed, the first IPv4 probe from (1) no longer
           "falls down a 'hole'" and gets lost (closure- and accounting-
           wise).

            * With this fix, the first IPv4 probe is no longer a complete
              throwaway--it actually succeeds. However, since it does so,
              it becomes the first of the two redundant IPv4 checks.

By employing '__connman_wispr_cancel', 'cancel_online_check' quells the
first IPv4 check triggered from 'default_changed' and
'start_wispr_if_connected' and replaces it, fully (in BOTH the service
and WISpr modules), with the second IPv4 check triggered from
'service_ip_bound', 'address_updated', and 'start_online_check'.
---
 src/service.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/src/service.c b/src/service.c
index d78ed0123160..9f6e28d34be4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1594,6 +1594,19 @@  static void cancel_online_check(struct connman_service *service,
 		service->online_timeout_ipv4,
 		service->online_timeout_ipv6);
 
+	/*
+	 * 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.
+	 */
+	__connman_wispr_cancel(service, type);
+
+	/*
+	 * Now that the reachability check has been cancelled in the WISPr
+	 * module, cancel any outstanding check that may be scheduled in
+	 * this module.
+	 */
 	if (type == CONNMAN_IPCONFIG_TYPE_IPV4 &&
 		service->online_timeout_ipv4) {
 		g_source_remove(service->online_timeout_ipv4);
@@ -1936,6 +1949,11 @@  static void complete_online_check(struct connman_service *service,
 		type, __connman_ipconfig_type2string(type),
 		success, err, strerror(-err));
 
+	if (!success && err == -ECANCELED) {
+		DBG("online check was canceled; no action taken");
+		return;
+	}
+
 	if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
 		interval = &service->online_check_interval_ipv4;
 		timeout = &service->online_timeout_ipv4;