connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: connman@lists.linux.dev
Cc: Daniel Wagner <wagi@monom.org>
Subject: [PATCH v2 2/3] wispr: Fix context refcounting in wispr_portal_request_portal()
Date: Wed,  7 Sep 2022 20:52:20 +0200	[thread overview]
Message-ID: <20220907185221.2981-3-wagi@monom.org> (raw)
In-Reply-To: <20220907185221.2981-1-wagi@monom.org>

The wispr_portal_request_portal() function is expected to read until
there is no data. Hence, the wp_context refcount is supposed to be
hold on while reading.

Furthermore, we should not return early when we read the
X-ConnMan-Status header. Instead we are supposed to go through the
normal return path so that we cleanup any added routing entries. Thus,
we also don't need to update the refcount in this code path as we
handle it at the main return path.

Fixes: 416bfaff9888 ("wispr: Update portal context references")
---
 src/wispr.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/wispr.c b/src/wispr.c
index 9b27af5fff55..a7562e8462f3 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -537,7 +537,8 @@ static bool wispr_route_request(const char *address, int ai_family,
 static void wispr_portal_request_portal(
 		struct connman_wispr_portal_context *wp_context)
 {
-	DBG("");
+	DBG("wp_context %p %s", wp_context,
+		__connman_ipconfig_type2string(wp_context->type));
 
 	wispr_portal_context_ref(wp_context);
 	wp_context->request_id = g_web_request_get(wp_context->web,
@@ -753,7 +754,7 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
 		if (length > 0) {
 			g_web_parser_feed_data(wp_context->wispr_parser,
 								chunk, length);
-			wispr_portal_context_unref(wp_context);
+			/* read more data */
 			return true;
 		}
 
@@ -783,8 +784,6 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data)
 		if (g_web_result_get_header(result, "X-ConnMan-Status",
 						&str)) {
 			portal_manage_status(result, wp_context);
-			wispr_portal_context_unref(wp_context);
-			return false;
 		} else {
 			wispr_portal_context_ref(wp_context);
 			__connman_agent_request_browser(wp_context->service,
@@ -996,7 +995,8 @@ int __connman_wispr_start(struct connman_service *service,
 	struct connman_wispr_portal *wispr_portal = NULL;
 	int index, err;
 
-	DBG("service %p", service);
+	DBG("service %p %s", service,
+		__connman_ipconfig_type2string(type));
 
 	if (!wispr_portal_hash)
 		return -EINVAL;
-- 
2.37.2


  parent reply	other threads:[~2022-09-07 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 18:52 [PATCH v2 0/3] Fixes wispr refcount and cleanups Daniel Wagner
2022-09-07 18:52 ` [PATCH v2 1/3] service: Track online check for IPv4 and IPv6 separately Daniel Wagner
2022-09-07 18:52 ` Daniel Wagner [this message]
2022-09-07 18:52 ` [PATCH v2 3/3] wispr: Simplify the IP version check Daniel Wagner
2022-09-07 18:57 ` [PATCH v2 0/3] Fixes wispr refcount and cleanups Daniel Wagner

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=20220907185221.2981-3-wagi@monom.org \
    --to=wagi@monom.org \
    --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 NNTP newsgroup(s).