ConnMan network manager
 help / color / mirror / Atom feed
From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Subject: [PATCH] Terminate all online check handling in one function.
Date: Mon, 6 Nov 2023 13:11:06 -0800	[thread overview]
Message-ID: <C0F0B144-2996-4453-B7CF-CF4E87A81FB1@nuovations.com> (raw)

This modifies 'portal_manage_status' by moving the unconditional
transition of the service to the 'online' state for which a HTTP-
based reachability check was successfully completed to the callback
provided to '__connman_wispr_start', specifically,
'complete_online_check'. This places all handling, both failure and
success, of HTTP-based reachability checks in a single, auditable
location in a single function in a single source file.
---
 src/service.c |  9 ++++++++-
 src/wispr.c   | 10 +---------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/service.c b/src/service.c
index 03e23618..dc9fa3ac 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1845,7 +1845,14 @@ static void complete_online_check(struct connman_service *service,
 		redo_func = redo_wispr_ipv6;
 	}
 
-	if(!enable_online_to_ready_transition)
+	if (success) {
+		__connman_service_ipconfig_indicate_state(service,
+			CONNMAN_SERVICE_STATE_ONLINE,
+			type);
+
+		if (!enable_online_to_ready_transition)
+			return;
+	} else if (!enable_online_to_ready_transition)
 		goto redo_func;
 
 	if (success) {
diff --git a/src/wispr.c b/src/wispr.c
index 0004ff57..64c94a4d 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -97,7 +97,6 @@ static GHashTable *wispr_portal_hash = NULL;
 
 static char *online_check_ipv4_url = NULL;
 static char *online_check_ipv6_url = NULL;
-static bool enable_online_to_ready_transition = false;
 
 #define wispr_portal_context_ref(wp_context) \
 	wispr_portal_context_ref_debug(wp_context, __FILE__, __LINE__, __func__)
@@ -480,11 +479,7 @@ static void portal_manage_status(GWebResult *result,
 				&str))
 		connman_info("Client-Timezone: %s", str);
 
-	__connman_service_ipconfig_indicate_state(service,
-					CONNMAN_SERVICE_STATE_ONLINE, type);
-
-	if (enable_online_to_ready_transition)
-		wp_context->cb(service, type, true);
+	wp_context->cb(service, type, true);
 }
 
 static bool wispr_route_request(const char *address, int ai_family,
@@ -1128,9 +1123,6 @@ int __connman_wispr_init(void)
 	online_check_ipv6_url =
 		connman_setting_get_string("OnlineCheckIPv6URL");
 
-	enable_online_to_ready_transition =
-		connman_setting_get_bool("EnableOnlineToReadyTransition");
-
 	return 0;
 }
 
-- 
2.42.0



             reply	other threads:[~2023-11-06 21:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 21:11 Grant Erickson [this message]
2023-11-07 19:03 ` [PATCH] Terminate all online check handling in one function Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C0F0B144-2996-4453-B7CF-CF4E87A81FB1@nuovations.com \
    --to=gerickson@nuovations.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).