From patchwork Tue Mar 4 01:10:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999720 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA8935946 for ; Tue, 4 Mar 2025 01:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; cv=none; b=hw+RvN9VZXFCVOHyleP3Ja6B94PzpN3znX60qJwq4UWphszBd5uJRjxzIZIsYk54aWXFXETqZjNaUKk7eGJ7jlO7G6XQXqQH1kvj9h3mpV0c0vSsUbgUAUpCgJJMfr6QM+fkZf3/Q0XMlOWvejbssP3WwUXNl+2UGZK8jfQk8EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; c=relaxed/simple; bh=6ilmkFe52ejZth/1ZI3S7WNLy0LS4D38LdRlZERwPak=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nj0N04m3Bz7ZIdNVQWRcpeDut9tI+kaYy2FegDFU8G88W19SoroulSrCNfj1r8xLB+Ht8a9monfeN5HvNHa6fXmnkUzWg/d6lJGOpL36bI2wqUMSTofOM/Ds28Mh7UctRF+pXV51rdMkZL1DxjqldITMSuTN7AqxLn8GOZxzo2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=GQ0FV4LB; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="GQ0FV4LB" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id EB2D3164B27 for ; Mon, 3 Mar 2025 20:11:15 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id A3754124FD2 for ; Mon, 3 Mar 2025 20:11:15 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 01/22] gweb: Leverage 'GWEB_HTTP_STATUS_CODE_UNKNOWN' mnemonic. Date: Mon, 3 Mar 2025 17:10:52 -0800 Message-ID: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=n+7n+by2+5K9Dr347n4l+wwIKt/CYoOiG6OS+ui3LbA=; b=GQ0FV4LB9/1J9Q6r/TGaLmUkxwwcE8WuvRBrdnqvxyWH5jT5F77bqaBnl9xmbVp5FBe9V0hpPKoThj0nUrePEy4p87wGKa9ZBsjsdY5Wvj4j2rYM2PuJSAMl7JiaGP9VFLWvH+F+auxh3Ul6OPneCY1V8VtIrTtXTyfMKYhsGHTh++0+q81Ivl8Inkn5kd4nhCHzEfiL+Jwzfmakf/gmSAXkJGwcYMNDKvO4CCmo2TCC9e77NvQGXiqGbZ/UitnOdeB3GSfSEeo2ZiQZBtcH9JW39kjMP0nk43bz6bG2YCuOususAkZr6hOyYlNWzToA2Gv3pOf3UwXx3h5vYU/Mcg== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 In the GWebResult structure, the 'status' data member is effectively nullable with the GWEB_HTTP_STATUS_CODE_UNKNOWN mnemonic representing the "null" value. Consequently, use the GWEB_HTTP_STATUS_CODE_UNKNOWN mnemonic rather than zero (0) to make that intent and pattern clear throughout the code. --- gweb/gweb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gweb/gweb.c b/gweb/gweb.c index ce49e8d3dfc1..8e0b79c52254 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1189,7 +1189,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, str = session->current_header->str; - if (session->result.status == 0) { + if (session->result.status == GWEB_HTTP_STATUS_CODE_UNKNOWN) { unsigned int code; if (sscanf(str, "HTTP/%*s %u %*s", &code) == 1) @@ -2429,7 +2429,7 @@ bool g_web_cancel_request(GWeb *web, guint id) guint16 g_web_result_get_status(GWebResult *result) { if (!result) - return 0; + return GWEB_HTTP_STATUS_CODE_UNKNOWN; return result->status; } From patchwork Tue Mar 4 01:10:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999721 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3042D35966 for ; Tue, 4 Mar 2025 01:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; cv=none; b=DR85pm8q1BgaqUe7wF3DkiJJYEKaepBmjQ49nFU+ir356tWG8U/8t3w8iJyeDTbI9dxiv3vt5zDEHBK8g/YIkfGplpmf/hY+83mKNv8CQloz5vTyinndmSP0yfSwVrmzDmZoU4rO4BQEYXVKFqcrW3IfAVRUazEPUJgjzeYRdy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; c=relaxed/simple; bh=LL2u+EZlVVABNibQgbxpMTLT/lTwI18Y1qx7Bl68zr8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LZwX1YosGUewyO6VInhMZ7haPOZ83FsRbKIl3U0zyIdH+dK1hiOCdUOfMnWDAybhXLl9+jo/IUobxx7HUKqskIthm7tGnPGJrfgUUmlbEmQlH6BUUWIVxTZ71ULfIgbbAVpD4SRvQ8XvCOC/gm1VNtU0hb0bB9wVHUAD1sTy/XA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=cHxbFwhZ; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="cHxbFwhZ" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 639AC164B43 for ; Mon, 3 Mar 2025 20:11:16 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 1AB0B124FD2 for ; Mon, 3 Mar 2025 20:11:16 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 02/22] gweb: Refactor 'received_data' into 'received_data_{finalize,continue}'. Date: Mon, 3 Mar 2025 17:10:53 -0800 Message-ID: <8f55c77f87703048d35509d4aaf014a9bc37d23d.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=MuyU4ipqjbcl+iZQJhZ8QLaI0UsZlmhTZ3nBit5XtSE=; b=cHxbFwhZP3fKHNDD1yK0Te8iJM/NOAUek6nP3nkf9cxljsbaEa/cz8XDCYa7n3t99ovXmGYRCIzkRn5vyPy9Hf+0ySty/T0O7ZeICJq3q8iKUCeA4zBBD1ewkIBdcweCeVhVwAyp1DnAFOMKEHYKmRAW62CCpNBgoIJgY57FmpznBV3PZQD2HJaZTqbgrMWoA9YY0VWbUcmgDXzzMfp+G0dlIFHPw7vqDune5Dw/SCnTDkQL3zO4aNg8t1lJhtSKC3dDRKSEqSVAPPjLL5PLzVDu5k+Pvc6hNYxTqX1BI/ULJMNkrpTk0mAx4xJM2c+AjSSZ+itYu9ukj+l2kvi3zA== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 The receive-data-and-process-it path for the glib I/O add watch received data handler was already sufficiently long to warrant its own function. That now exists and 'received_data_continue'. While short enough at present, as further error-handling cases are developed, the finalization logic for an outstanding web request session warranted its own peer function to 'received_data_continue'. That now exists as 'received_data_finalize' where error or EOF cases are now handled. --- gweb/gweb.c | 88 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 26 deletions(-) diff --git a/gweb/gweb.c b/gweb/gweb.c index 8e0b79c52254..d4bdbdd641f5 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1091,37 +1091,22 @@ static void add_header_field(struct web_session *session) } } -static gboolean received_data(GIOChannel *channel, GIOCondition cond, - gpointer user_data) +static void received_data_finalize(struct web_session *session) { - struct web_session *session = user_data; - guint8 *ptr = session->receive_buffer; - gsize bytes_read; - GIOStatus status; + const guint16 code = GWEB_HTTP_STATUS_CODE_UNKNOWN; - cancel_connect_timeout(session); + session->transport_watch = 0; - if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { - session->transport_watch = 0; - session->result.buffer = NULL; - session->result.length = 0; - call_result_func(session, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); - return FALSE; - } - - status = g_io_channel_read_chars(channel, - (gchar *) session->receive_buffer, - session->receive_space - 1, &bytes_read, NULL); + session->result.buffer = NULL; + session->result.length = 0; - debug(session->web, "bytes read %zu", bytes_read); + call_result_func(session, code); +} - if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN) { - session->transport_watch = 0; - session->result.buffer = NULL; - session->result.length = 0; - call_result_func(session, GWEB_HTTP_STATUS_CODE_UNKNOWN); - return FALSE; - } +static bool received_data_continue(struct web_session *session, + gsize bytes_read) +{ + guint8 *ptr = session->receive_buffer; session->receive_buffer[bytes_read] = '\0'; @@ -1210,6 +1195,57 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, return TRUE; } +static gboolean received_data(GIOChannel *channel, GIOCondition cond, + gpointer user_data) +{ + struct web_session *session = user_data; + gsize bytes_read; + GIOStatus status; + + /* We received some data or condition, cancel the connect timeout. */ + + cancel_connect_timeout(session); + + /* If there was a low-level I/O condition or error, there is + * nothing more to do; simply fail the request. + */ + + if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { + session->transport_watch = 0; + + session->result.buffer = NULL; + session->result.length = 0; + + call_result_func(session, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); + + return FALSE; + } + + /* Attempt to read received data from the channel. */ + + status = g_io_channel_read_chars(channel, + (gchar *) session->receive_buffer, + session->receive_space - 1, &bytes_read, NULL); + + debug(session->web, "bytes read %zu status %d", bytes_read, + status); + + /* Handle post-channel read errors, which could be either + * G_IO_STATUS_ERROR or G_IO_STATUS_EOF. + */ + if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN) { + received_data_finalize(session); + + return FALSE; + } + + /* Otherwise, continue the session request and process the + * received data. + */ + + return received_data_continue(session, bytes_read); +} + static int bind_to_address(int sk, const char *interface, int family) { struct ifaddrs *ifaddr_list, *ifaddr; From patchwork Tue Mar 4 01:10:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999722 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B103A8D2 for ; Tue, 4 Mar 2025 01:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; cv=none; b=JyeRl1ObkYAVBFT4Ut15h6HZKIJJsD8Yb8NKecQS+9laBhwRDQpwfTVGsfrnr6OYoE9vdY153ItwDbujGwk5G1IFIOgRs5fr7S6nRHXCOowN4CeGK8fE/EUyVVLUE+sG/3Cj2OrjWwBdcQvq8/TO/NXUSeG4eDlcOoJ595FscwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; c=relaxed/simple; bh=47fuW5Tuk/YBmLZBmPu+sGctbNk3+gYm9LTpx6g5i+s=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KwLILBFxy6vSzqRwkSknF/u+N1pp7ukGZO2q1BKgR3ReHHP07u1V2802q9fSomRaXOdQHZDViZtNvTKvW4sxgJd4KNA4mnjwwVkk5NtyS/HrTe8LGXbrBbuXY/aQKaHpY+PhW5oCs7Wo3KnoGASaji8HIkV93wA44ItJ0eqlCU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=FuxJUW0l; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="FuxJUW0l" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id DA719164B4A for ; Mon, 3 Mar 2025 20:11:16 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 8755C124FD2 for ; Mon, 3 Mar 2025 20:11:16 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 03/22] gweb: Added 'g_web_result_has_headers'. Date: Mon, 3 Mar 2025 17:10:54 -0800 Message-ID: <33b4c08a164f2a8030dd86e254d79f25ac7762de.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=Ra9UY3AraOCIXWWAyyZPT2eKq3kmnD1hDB2+GcQ6DPE=; b=FuxJUW0lqjsyMH0trk630i40QQAh85DezKc5GAq5VvuoKPUcjJej5ySJb1JM2C9wZ6wQ9UU3rZjBMtqJZJV7F0Eouok+B18QalsuKJLVVF197P2p1d4PrxmfCm1jli+vQQGY8tuWeRvYjKLp3E6OjHL3FvSqHNj8ad7D8xUuesUYJgx4WLENGW9kJ4IVWsVf07nOvjQAQVSH/Bs/vElMh4KUCF/L67tA5Al8+F6XI3EVabw+dvKW1g1suslng6O0IjFzLGuKykNvFzj8CirHtzxudirKUCIGzf8iAkNMqyDBt2UBWSIM5w/xI0oQDQ396ZavNcQzr7MRXedouk75LA== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Return whether the web session request result has any HTTP headers and, if requested, the header count. --- gweb/gweb.c | 16 ++++++++++++++++ gweb/gweb.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index d4bdbdd641f5..76f01c44b88f 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -2504,6 +2504,22 @@ bool g_web_result_get_header(GWebResult *result, return true; } +bool g_web_result_has_headers(const GWebResult *result, + guint *count) +{ + guint size; + + if (!result) + return false; + + size = g_hash_table_size(result->headers); + + if (count) + *count = size; + + return size > 0; +} + struct _GWebParser { gint ref_count; char *begin_token; diff --git a/gweb/gweb.h b/gweb/gweb.h index 7c65aebf4698..90cccadbe883 100644 --- a/gweb/gweb.h +++ b/gweb/gweb.h @@ -166,6 +166,8 @@ guint16 g_web_result_get_status(GWebResult *result); bool g_web_result_get_header(GWebResult *result, const char *header, const char **value); +bool g_web_result_has_headers(const GWebResult *result, + guint *count); bool g_web_result_get_chunk(GWebResult *result, const guint8 **chunk, gsize *length); From patchwork Tue Mar 4 01:10:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999723 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 132413BBC9 for ; Tue, 4 Mar 2025 01:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; cv=none; b=RMjt9CcYxux1oQeZKfoWDONUFY6e0HjnI3LkdSFFr5oJFncRw8h4QmhqR1aBOUU7sHF4HFykZTHfN0nrxT9lDmsNIdThHeLIvETIfEkLlEMo+m3TU0AXp+UTPdrvxRbW6Fnm+qsL0mgnyBFbvQxGfuRKF7B9iEsquUWWEz6z7BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050685; c=relaxed/simple; bh=45/I3XKHPZk4K7emAp1wjcllQpMZb3IDOmizSdr8Qqw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fT9DjXVkuo6uUSPFBvdCS+rrQoqejzinLTqOQrcxcAKSCULJ8vZumItQtB5crFRYKzbOJEpNhWj0cDFAV/fJ+T0t/U3xUX6UK/vEFbycrDaxvvo5GAsq4bETvPW2T0U2TZ/MVmUR40nrJufU9RNC3JWlFP7OjGlXbT+2L2IqbtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=inGKM/8r; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="inGKM/8r" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 53411164B4E for ; Mon, 3 Mar 2025 20:11:17 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 0A6F7124FD2 for ; Mon, 3 Mar 2025 20:11:16 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 04/22] gweb: Add documentation to 'g_web_result_has_headers'. Date: Mon, 3 Mar 2025 17:10:55 -0800 Message-ID: <41b6aad1ec7965c887d03910babcb19f37d26c1b.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=v3UWlyP63X+L3BtrjIGRHntqZVBmKWlSIv+N0LDC+OE=; b=inGKM/8rhgVWqPmmS86kSUnRgqIE3GuQlaGts4o7pQPMg91pPGLKApdoiX7cESbDutwnQ0cDGS5AxmZC5mBR9dN+3zrBNDfO/xVY7E+jFkVqyymf/ug+Gf11QnR5k9FYvYesqSHEq0vwvpj7gV4o+4GZ3TNsQBz2J6IrdbOTCiL7viIXMe4qJgFjtqmlGzW0stfUAm9PJ/R1D7vuSmAgxkjsFF24n55oUA8XLziD9V6mVpC+3t7wRnMslIUWtIWqRRq/tfAeU/zJQRP9zr20jo9OVNSy+VGwdiCrnYzlTKfbAWpT125/qmOSVJHJI0jEQT4dcgsompf2vkjtMxFgMw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'g_web_result_has_headers' function. --- gweb/gweb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index 76f01c44b88f..d79d2d0808cd 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -2504,6 +2504,25 @@ bool g_web_result_get_header(GWebResult *result, return true; } +/** + * @brief + * Return whether the web session request result has any HTTP + * headers. + * + * @param[in] result A pointer to the immutable web session + * request result for which to determine if there + * are any HTTP headers. + * @param[out] count An optional pointer to mutable storage for the + * number of HTTP headers associated with @a + * result. + * + * @returns + * True if there are one or more HTTP headers associated with @a + * result; otherwise, false. + * + * @sa g_web_result_get_header + * + */ bool g_web_result_has_headers(const GWebResult *result, guint *count) { From patchwork Tue Mar 4 01:10:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999724 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE14F35946 for ; Tue, 4 Mar 2025 01:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; cv=none; b=LFsPSynwqlyfMYIFzEGE3BLD1rA1v9Df2/Fs27He1sPoiQYG4LPCuDkvUjgBQUuu/aTak8gBoHfjmrRz1NRWdX6YxSY7MpVh53JxAJKIPGMKKiMZn/UzzjSet2sSmm+lqxaBbwbn99/rUvCSBmm9oZ6DJXFXqULwn+g7q4cfZQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; c=relaxed/simple; bh=SLsoLtGt4glfIO7MTGQCzMsadM7FpXEPZJAXxkDnygE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nT/akIdzzVPOfclqD8gp79qMN/niR1cZZQ6Zu63yNeiWKt/+n99jmdPFbBg62dLuaIOgWkH1xpQ3ny9itcdY4wKU5TfR8bAIuRRHMlPoPnx5QRNkqgcD11d5o4vzWFylsuCSYoso84jUKDNCyTebyxoLcGw7CUMmMDXP+5VR4CY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=fI5uD7ya; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="fI5uD7ya" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id C09BA164B4F for ; Mon, 3 Mar 2025 20:11:17 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 77605124FD2 for ; Mon, 3 Mar 2025 20:11:17 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 05/22] gweb: Added 'g_web_result_get_err'. Date: Mon, 3 Mar 2025 17:10:56 -0800 Message-ID: <3e0b57485a7f50f031d7853b01a40a4821704e05.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=2phLsebY6ZrDr69vpjoZYmfgNhsUrpxApHY06pjvRi4=; b=fI5uD7yaTsO0Ov+Gee7634ata6PH8sch5Z7Jh75ayqp3qRrwc5ddbrQWcm3fDohSUMV47+W3yMDafrx/oU3BKnJF9hAwsji5THpLJuJSMvWVUh3mLBi5kwTvj7DcyDF5Ma+i4gOqOEMB/CH/NCn19aW3mMucWnrVhYhaFYigfRTrCm1S9NwegKipdMFEp3ycZ00pYYLfqV72+6bDkUqaQFlzfUYZooGCkj8GM+h9nozTCt/aHh9NkJJPELegByBtIO27+CrFU5XvZdb/AzyuD17lwmsF1EfZ8OBsp14pn6gLH7+QBFWlny0s2ImOveVCBsc+joMPdu/rdopsrHDlUQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Returns the operating system error, if any, associated with the web session request result. --- gweb/gweb.c | 9 +++++++++ gweb/gweb.h | 1 + 2 files changed, 10 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index d79d2d0808cd..6ada0dfa571c 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -55,6 +55,7 @@ enum chunk_state { }; struct _GWebResult { + int err; guint16 status; const guint8 *buffer; gsize length; @@ -2462,6 +2463,14 @@ bool g_web_cancel_request(GWeb *web, guint id) return true; } +int g_web_result_get_err(const GWebResult *result) +{ + if (!result) + return -EINVAL; + + return result->err; +} + guint16 g_web_result_get_status(GWebResult *result) { if (!result) diff --git a/gweb/gweb.h b/gweb/gweb.h index 90cccadbe883..e9a8eda9f8f7 100644 --- a/gweb/gweb.h +++ b/gweb/gweb.h @@ -162,6 +162,7 @@ guint g_web_request_post_file(GWeb *web, const char *url, bool g_web_cancel_request(GWeb *web, guint id); +int g_web_result_get_err(const GWebResult *result); guint16 g_web_result_get_status(GWebResult *result); bool g_web_result_get_header(GWebResult *result, From patchwork Tue Mar 4 01:10:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999725 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE18C35966 for ; Tue, 4 Mar 2025 01:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; cv=none; b=Mbabn419SWH//8klqVxoVCqvZzSMokwPDF+t4n23OsOHPEp7WeajSWgAntnx/PXHAM2PBZIO1//ZuHWpzNnvbOqgyJOlVidovBi5R2MXgCZqRvO67poxvd5yWC3fEATiLeum+biVNKvwLbMXSst/dwSjjtwS9UDEnT6LHmvfP6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; c=relaxed/simple; bh=ARM2Zg3E0H5Rgnjib9vPQZxSQjL7ZmsZ+XQGdyJu8u8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jaCnpOuTO2QjAw2Y3kl10R/klGnNJzDU72kahJi6eKACG+cuKLnia8BR3JpKXswApfsYau9ueM5OSMZxTTTM2LHFX3INV7Qu5NuIlRd9q9nBtrzBPhmMgEwjHYvA3xpHuH5qYkQYE6VAgR9W6m/i4Ag9PL8OiDzzkTs2bSb+k44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=mFfCO1GA; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="mFfCO1GA" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 3869A164B50 for ; Mon, 3 Mar 2025 20:11:18 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id E4459124FD2 for ; Mon, 3 Mar 2025 20:11:17 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 06/22] gweb: Add documentation to 'g_web_result_get_err'. Date: Mon, 3 Mar 2025 17:10:57 -0800 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=6BiM3CXRbEUsETTTn0rWxac0vZUilT2kQKvl4q5RImk=; b=mFfCO1GAU1R/KtwOCkF3c9xwbdCY3dH0iZNkz9uvqCTvMiA2wwnDusW+J596LGBhv+DNaNMDD9AJvOpjNzUMJSSRjPwrlvNxDnEsO7Z61iyhzW2vlY/eMj9NB4YVAYzw5DSt5YSUmKUSnx13JT7HEAD9Ki69SaQ/SQoAmdPX8IJJ2Y18t4MWAbt3tJwuh99fdVvdB2jImB/yjQUUZHXZMEjeyO3Or8TssueTv3B9uKDMt3aZyHh9ZHKamUSQ0u88JJb4tc3+UFeAb8Fhi5P4spwZGZJrQcoFX42gpPF+GHGHfhp3fGLIjnQEly3aG/7JtBeeILrEnKglIc6s2O0NGw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Adds documentation to the 'g_web_result_get_err' function and the associated 'struct _GWebResult' 'err' data member. --- gweb/gweb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index 6ada0dfa571c..72f83d8f27e4 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -55,6 +55,12 @@ enum chunk_state { }; struct _GWebResult { + /** + * Operating system error, if any, associated with the request. + * + * 0 on success; otherwise, < 0 (negate to arrive at a POSIX + * domain error number). + */ int err; guint16 status; const guint8 *buffer; @@ -2463,6 +2469,22 @@ bool g_web_cancel_request(GWeb *web, guint id) return true; } +/** + * @brief + * Returns the operating system error, if any, associated with the + * web session request result. + * + * @param[in] result A pointer to the immutable web session + * request result for which to return the + * operating system error. + * + * @returns + * 0 on success; otherwise, < 0 (negate to arrive at a POSIX + * domain error number). + * + * @sa g_web_result_get_status + * + */ int g_web_result_get_err(const GWebResult *result) { if (!result) From patchwork Tue Mar 4 01:10:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999728 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07A61433BE for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; cv=none; b=YSov9adOGVk3t9ZJemZlL3q09Ir4qVIO/DgDDuwDrwOv48rhmHrc1GlPPukfIo1uUNBoJJUpBFL88GKGpUJ66FZe2CP9k6u37jtFISnH0dec5wtFhYIpogxqHn21kgu/Z+N1ugDYcpEsSgteYLIGjFy7vAlTeMR7+e1nTj4nsGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; c=relaxed/simple; bh=4nj74Xta146bwIYyM6e+pXmc3KZa6CdkUjRcifYYYWg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DRQ/YhUylAyClMscb4uhdJY3XQiprolEAttcHFdDgLZHQe2+MMI7I/JzqtRYE9m7DkHDMe/DVBsLgMeYUuIA4+Lkmk5GQ1y8GOby9telckMtksip9UONWqPm3lK5LijJpejSb1gJo005+SYv8Jn6uViAVDXmsgqdriSIlvOfFlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=GcmstVpG; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="GcmstVpG" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id A5B5C164B51 for ; Mon, 3 Mar 2025 20:11:18 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 5C253124FD2 for ; Mon, 3 Mar 2025 20:11:18 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 07/22] gweb: Add an OS err parameter to 'call_result_func'. Date: Mon, 3 Mar 2025 17:10:58 -0800 Message-ID: <4358a366915e876dc60ac5ea5dc2e3846601b438.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=NK7Zt5YCiFxbYL1MjlRCqeVaXwqWgGmwUCiu6Pncj1g=; b=GcmstVpG+t+fWK8U6pFjsoQdGkB+jQ/yvLeAIjvcJjY4DngW2ya2uoeCvLNj6sbv2Ztm3UzM+1l4ZeHvRc5KK193KNOuSiaRV2G+3sUoRN7h6PVEhzUva12FKRdAYSIypW4jO57j4BD7JayaR1o+xSdTLxH1W7QbDQ3E78oqL64gveqRkqAtGEmLMnWmiW8jV16gU1ftxo1eLSM1JE1lkVAQ8O4Bmwa/vdwl/gSHcAUj2YcFahPf2c26KHMBTpihYwUiP1vi5YnIytLHx31MuF5pebEfVVVQPrkcOxxqZAr2Te80T8nMEG/qs6sDeCwNgkgU6207GYk86qwozW93Ew== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 This allows populating the 'struct _GWebResult' 'err' data member for operating system-related web request session failures and the use of 'g_web_result_get_err' for interested clients, such as WISPr. --- gweb/gweb.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gweb/gweb.c b/gweb/gweb.c index 72f83d8f27e4..f5accf80cbeb 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -164,17 +164,21 @@ static void _debug(GWeb *web, const char *file, const char *caller, va_end(ap); } -static inline void call_result_func(struct web_session *session, guint16 status) +static inline void call_result_func(struct web_session *session, + int err, guint16 status) { + debug(session->web, "session %p err %d status %d result_func %p", + session, err, status, session->result_func); if (!session->result_func) return; + session->result.err = err; + if (status != GWEB_HTTP_STATUS_CODE_UNKNOWN) session->result.status = status; session->result_func(&session->result, session->user_data); - } static inline void call_route_func(struct web_session *session) @@ -219,7 +223,7 @@ static gboolean connect_timeout_cb(gpointer user_data) session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, GWEB_HTTP_STATUS_CODE_REQUEST_TIMEOUT); + call_result_func(session, -ETIMEDOUT, GWEB_HTTP_STATUS_CODE_REQUEST_TIMEOUT); return G_SOURCE_REMOVE; } @@ -960,7 +964,7 @@ static int decode_chunked(struct web_session *session, if (session->chunk_left <= len) { session->result.buffer = ptr; session->result.length = session->chunk_left; - call_result_func(session, + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_UNKNOWN); len -= session->chunk_left; @@ -976,7 +980,7 @@ static int decode_chunked(struct web_session *session, /* more data */ session->result.buffer = ptr; session->result.length = len; - call_result_func(session, + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_UNKNOWN); session->chunk_left -= len; @@ -1002,7 +1006,7 @@ static int handle_body(struct web_session *session, if (len > 0) { session->result.buffer = buf; session->result.length = len; - call_result_func(session, + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_UNKNOWN); } return 0; @@ -1014,7 +1018,7 @@ static int handle_body(struct web_session *session, session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); } return err; @@ -1107,7 +1111,7 @@ static void received_data_finalize(struct web_session *session) session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, code); + call_result_func(session, 0, code); } static bool received_data_continue(struct web_session *session, @@ -1223,7 +1227,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); + call_result_func(session, -EIO, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); return FALSE; } @@ -2257,14 +2261,14 @@ static void handle_resolved_address(struct web_session *session) ret = getaddrinfo(session->address, port, &hints, &session->addr); g_free(port); if (ret != 0 || !session->addr) { - call_result_func(session, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); return; } call_route_func(session); if (create_transport(session) < 0) { - call_result_func(session, GWEB_HTTP_STATUS_CODE_CONFLICT); + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_CONFLICT); return; } } @@ -2285,7 +2289,7 @@ static void resolv_result(GResolvResultStatus status, struct web_session *session = user_data; if (!results || !results[0]) { - call_result_func(session, GWEB_HTTP_STATUS_CODE_NOT_FOUND); + call_result_func(session, 0, GWEB_HTTP_STATUS_CODE_NOT_FOUND); return; } @@ -2347,6 +2351,7 @@ static guint do_request(GWeb *web, const char *url, debug(web, "host %s", session->host); debug(web, "flags %lu", session->flags); debug(web, "request %s", session->request); + debug(web, "result_func %p", func); if (type) { session->content_type = g_strdup(type); From patchwork Tue Mar 4 01:10:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999732 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2502F524B0 for ; Tue, 4 Mar 2025 01:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; cv=none; b=e37nAjIcWzEX2m45mDmWWOAi/Z2pJNGJBjqn45RDek6XVNE9VlorcsJLw73bVjB8RZ3tfqETnOA0z13wzn7mG+sKdVGjHAmLNTK7eGzKBK8r5Puv+Aj2XTEZxEYgKIW/q++oK2t8rjq6NcUEZGKZQgk+3IYzWkKxclucIfDlJSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; c=relaxed/simple; bh=G/Qe3zKlTWADGLY8hQl3objaGVPcpvPxCLiBXVnopwU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gjPDenzQU55YqRc9NALqfTCEfoj0ra4GiTwRBMMdEAPeufdltwLzmo2OzMab4N1QK26cqSy3HluLdiyZ9tojDXDyalBHPwMaNtyBsuMvLG/2iKgOe739x+btWEo/RNvHk+znaSrCTVrb2uK1/A7uToYNGkp+e+YvYf1dP8i7/6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=Mo4RvECE; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="Mo4RvECE" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 1C3E7164B53 for ; Mon, 3 Mar 2025 20:11:19 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id C9372124FD2 for ; Mon, 3 Mar 2025 20:11:18 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 08/22] gweb: Add documentation to 'call_result_func'. Date: Mon, 3 Mar 2025 17:10:59 -0800 Message-ID: <5bca4dd1ae8cf27646239ffd4a1f3640cf455075.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=r/OwwCe7WVAb7p2me6Fo1ky5hBl9KQF3gIRNseVbf9M=; b=Mo4RvECEt0sPyGMDlRB80rQCn6a6r6vO8WP05rjbb2kpSCCevhW2j4KeQ3TLp8YugOLqLfA+USKOdRYUB5M1RUDyVy61kQ4A/Z6km5msJkckhcLA4IfuXCxEYmWQ+hnQx0ZnZeFdVQkhtJw/XjNVVf8P9XqpVJ8a7nTHMc3EUc9Q35BXeceO64jXIaR+WqlToiRSokVNrZ6pGP3ggEpaHEFmZ7i4AoDDFpg3a03Yeg/kT3bybmlccF4VXu0Z6kp7RX0S8LD6+VHU8Vt93Byf15HXQ96Y+ZCxhLE73tSMe4YysI2/6y/IcbftyqjhhWtnLUZ+/zb1XMpbuvW0KUVGZg== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'call_result_func' function. --- gweb/gweb.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index f5accf80cbeb..0256d622e00a 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -164,6 +164,34 @@ static void _debug(GWeb *web, const char *file, const char *caller, va_end(ap); } +/** + * @brief + * Invoke the closure callback associated with the web session + * request. + * + * This closes the specified web session request by invoking the @a + * result_func originally assigned in #do_request when the session + * was first initiated. + * + * @param[in] session + * A pointer to the mutable web session request for which to invoke + * the closure callback. + * + * @param[in] err + * Operating system error to set in the @a session result + * structure. + * + * @param[in] status + * HTTP status code on success to set in the @a session result + * structure. Note that #GWEB_HTTP_STATUS_CODE_UNKNOWN acts as a + * null value such that the status is only set if the value is + * not #GWEB_HTTP_STATUS_CODE_UNKNOWN. + * + * @sa do_request + * + * @private + * + */ static inline void call_result_func(struct web_session *session, int err, guint16 status) { From patchwork Tue Mar 4 01:11:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999727 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22CE63BBC9 for ; Tue, 4 Mar 2025 01:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; cv=none; b=WggILpIRLP3ptPREjZwfX4aqTpcgrmICrQM9r0a8Bxabk5jCat8vZgZCYa1HvI9dPlempVzTdUst6EIKQMxg52VVyCZDKSc9sJZJN2pbvQHJvhp0Bhw1VSkyxQw63Al2JLk9xZ5ltXqWrlOUzlsuQJgdCIcombY2hLMSQJFY07M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; c=relaxed/simple; bh=44HUdhk7dssEJ9PRfq7Z/GkqK4eShLJD9Y8TkVr78Xs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q6phmAfywukUCnfqSRrfthpCVvmSaMkNpuFLUFm4Y6M+FJYJBvoPnfEIBTmr2C5dF9QHdKkuXIiOmDafiCCRfH2KreDmJoEp0OYs/LB5Wy3Ut7Rjfhr+5UVOvLq12CAmIOAOfMf3zbSPsBw2P6pndgzWKWK3haJ5VnNtXVqD2f0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=aR5OUbkr; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="aR5OUbkr" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 889DC164B54 for ; Mon, 3 Mar 2025 20:11:19 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 3F9D21260D5 for ; Mon, 3 Mar 2025 20:11:19 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 09/22] gweb: Add documentation to 'g_web_result_get_status'. Date: Mon, 3 Mar 2025 17:11:00 -0800 Message-ID: <008c8a22cd569df0fb8c8f815d946b0bf730b419.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=aP//wlS8ILBKjvXLMQ+tpDDPz4EdrX5YOmp9j5T5if4=; b=aR5OUbkrYyTKcAOsHGfYbjm4tfd44EHHRZL/a9XZMHQIhWgnIys9CW4078v738kfnTvpPdN0f9NNEw6vKCFtP2zB7//a6Z3Xm9vsSRnc8THGKnQRJHVelLOKERfNgHu3yC6AcfaRRNOdAE7aVmuYfKu68bn7eRGhLpIRa2j4dHW6j6atsDS1wNUXuj3Z+5B7YyCqd/4Esu+Ynx17HEoJh5kl/HIDy7/F/A++tHvujzm24TMxRBzWa8WssiSpCaO3NF9nEcctnRphaWtG7AJ5do1jyu4fUk/T5jZRypNy157BkuFpZxxVVFIGxsth1Pp4imz8ic9N1Mr0V/IaR6WWEw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'g_web_result_get_status' function. --- gweb/gweb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index 0256d622e00a..ec72cd417a9c 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -2526,6 +2526,21 @@ int g_web_result_get_err(const GWebResult *result) return result->err; } +/** + * @brief + * Returns the HTTP status code, if any, associated with the + * web session request result. + * + * @param[in] result A pointer to the immutable web session + * request result for which to return the + * HTTP status code. + * + * @returns + * The HTTP status code. + * + * @sa g_web_result_get_err + * + */ guint16 g_web_result_get_status(GWebResult *result) { if (!result) From patchwork Tue Mar 4 01:11:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999726 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1348E3A8D2 for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; cv=none; b=YZTcAPmjP+QzG8RgWZlkLNFUa/Wu9yjxhIUTV5GZWpQnV5I4BIY/dBKKG8IDCWz7nBhHHdiasGAxvJpPoLd1cZB+02RdZVeVU9VFCQa3n3nfIZ1JtO0cKLiduu2b2WekwLtomn4Me0bTzeNtjL8P9G21bUETk46JRq5ZF5mQX6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050687; c=relaxed/simple; bh=lLyTWXL7x79r/g3/wtbcMIIO+tOP0FnKtNylLgg+43o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PGZsnhLrgTw3tA2brfbh3YhbSFHTPd/CfcsNWM/IZKLdDzFdZx1jvXJyD7m0+2Mt2WEzLdXfQrmWha21VXg08iT0yM7w3FtTHcecPHVBNfuDhPTsKSgC393QGRucsdE96H2hYZbTtzLAnYukuhLBptYBjnAU0neQoFddfgNAnQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=bKcJfyWb; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="bKcJfyWb" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 00FAA164B55 for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id AC5BB1260D5 for ; Mon, 3 Mar 2025 20:11:19 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 10/22] gweb: Add documentation to 'received_data'. Date: Mon, 3 Mar 2025 17:11:01 -0800 Message-ID: <0c04ea4d681879ea0fda5fa1e9c3e3a4d5543aee.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=8pFedP8XBuzudzXzX7zlchwUBRSP3uxNebmN75a3eto=; b=bKcJfyWbhe5TccclEnf8aAO4NwfcHqM862IXmTnOULf1q6jaqPTsJETHQORcuK+3jLrmexuDaIqCexUjZ8DsA3p9afqJH+ckjH022B1Z4baG+IVUKGNDJbY+apK4ANaCnBEhpZQObwaz8rEZFv41S90KOgFlF8JRUwfJT8PQO1c5Df+S0BNAwtwck2cO396k1WIyIRFbldfhxX9W3XxEWjueLUHL9DKqb+cgmOihizfjkTDqC6Qsk1+mLxVCDdb3y5YpHGbfPiz2j2Z4Tvo9A7XeCMBMvy2V0mFJC95oPEv6OVQ0lYmERpJdr/+lMGQOlH9eBJagUPSnxpagnQt3Ow== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'received_data' function. --- gweb/gweb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index ec72cd417a9c..78d4fb0517ff 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1234,6 +1234,28 @@ static bool received_data_continue(struct web_session *session, return TRUE; } +/** + * @brief + * Handle a glib I/O channel watch received data delegation for a + * web session request. + * + * This handles a glib I/O channel received data delegate for the web + * session request associated with @a channel. + * + * @param[in,out] channel A pointer to the glib channel that + * received data or a condition(s)/ + * event(s). + * @param[in] cond The conditions or events that + * generated this delegation. + * @param[in,out] user_data A pointer to the mutable web session + * request associated with @a channel. + * + * @sa received_data_finalize + * @sa received_data_continue + * + * @private + * + */ static gboolean received_data(GIOChannel *channel, GIOCondition cond, gpointer user_data) { From patchwork Tue Mar 4 01:11:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999731 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE63B537FF for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; cv=none; b=XjkXJnG/mhSgCdpxgcdduRlcNokopNd7nBJuGbyzkJwNiLewfcDCsxggsTigF6xxlD3GOyJhs3hm+BgqUAJwDE0+vLw9DxCvplUkq0wE1pJgJlMXh0zyQqiu0oRioTAhQwJbsN4ICN7r+NzMxY1yZlueW4Kdp+cnJumYVxZiANc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; c=relaxed/simple; bh=K2+y9qG9UIUWL2crGm/QZ1ZKQ9St4gs65NdBxqQ8jE4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T3ctYUo4usnlixQon9ofDPCAyHtgrpvMaud9Fv2s2kWbtl8IZOppqEyUrCJqxatOrqEfrjIhGYCJuL4QfXsDedFkTO8zjqsOWkWS7wuKf4ajZ8zU1t5BWv9jEh7wzRUIcWDGirCBHsjF0fmME1gcTBLEJxIUaenJVms6cKRMAcc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=O4vol6G2; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="O4vol6G2" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 6D36D164B56 for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 24B901262B0 for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 11/22] gweb: Close web request session finalization 'hole'. Date: Mon, 3 Mar 2025 17:11:02 -0800 Message-ID: <3e35d3f610c54761f9f3b54514d92272215230cc.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=ojYdfHzkhPpbTHzEcUutPyG7cA8mELrsffy7npJvxgY=; b=O4vol6G28OJQjvSy25y5mtIZyTQz2LNjmKGAKmf3p/WzDltAx/OgzfrmN2qZ6dRVSbXfKJKqYyKeYAg/lIevc77E4hGwSkmwHial4DMiN2/f72t9Y/PB7KxRrBA+4LhFOJW8eK1IWqK8dMcqeOrBqUhZYBaztt+ZXC5Eqnt0gpDBfgVkQYI1IzkcAnJcLC3FZAfhDUJBkOX9Bdi1v/5eP5i4sFql1hSvElXvORvdlANlLZsY472MgfdbgCwPFcDG8mJ+lmja3LPeqvW4yEwYttUcsy0fh5+r7MIUYc6LlYNvZCBbZa9BPVdn2FCIMj/apawnhkkP8AnFeXpPEhms1A== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 There exist two "holes" in the finalization of web request sessions that can, for example in a client such as WISPr leave one or both of IPv4 and IPv6 "online" HTTP-based Internet reachability checks "dangling" and non-renewing such that an expected active, default network service failover does not occur when it should. The first of those two failure "holes" involves an end-of-file (EOF) condition. In the normal case, there are a series of one or more data receipts for the web request as headers and, if present, the body of the request response are fulfilled. When there is no further data to send, the final receive completes with 'g_io_channel_read_chars' returning 'G_IO_STATUS_EOF' status and zero (0) bytes read. This should and does lead to a successful EOF closure of the web request. However, there is a second EOF case that appears to happen with a random distribution in the nginx server backing the default "online" HTTP-based Internet reachability check URLs, 'ipv[46].connman.net/online/status.html'. In that case, the nginx server appears to periodically do an unexpected and spontaneous remote connection close after the initial connection but before any data has been received. Presently, all such failures hit the same error-handling block which effectively maps such a failure to the effective "null" 'GWEB_HTTP_STATUS_CODE_UNKNOWN' status value. Unfortunately, clients such as WISPr have no way to distinguish this as an actual failure or success and so it lands on the case: case GWEB_HTTP_STATUS_CODE_UNKNOWN: wispr_portal_context_ref(wp_context); __connman_agent_request_browser(wp_context->service, wispr_portal_browser_reply_cb, wp_context->status_url, wp_context); which does not "bookend" the original, initiating WISPr web request and leaves the original request "dangling" and non-renewed, eventually leading to the aforementioned "hole". To handle this failure EOF case, if GWeb asked for a non-zero amount of data from 'g_io_channel_read_chars' but received none and have accumulated no headers thus far upon receiving the status 'G_IO_STATUS_EOF', then GWeb assumes that the remote peer server unexpectedly closed the connection, and synthesize the error '-ECONNRESET' with the same HTTP status "null" value of 'GWEB_HTTP_STATUS_CODE_UNKNOWN'. With the addition of the new 'g_web_result_get_err' interface, clients such as WISPr can now distinguish between a low-level operating system error in which no HTTP data was received and an operating system success in which HTTP data was received and the status can be disguished by the HTTP status code. The second of the two failure "holes" involves the case where 'g_io_channel_read_chars' returns 'G_IO_STATUS_ERROR' status. Prior to this change, this funneled to the same "hole" as the 'G_IO_STATUS_ERROR' failure with the same consequence to clients such as WISPr. To handle this error case, GWeb now passes a glib GError pointer to 'g_io_channel_read_chars'. If it is set, GWeb maps the resulting error domain/code pairs to negated POSIX domain errors, and default to '-EIO' if no suitable mapping can be made. As with the failure EOF case, this allows clients to distinguish and handle such failures and to successfully "bookend" their initial web request. --- gweb/gweb.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 7 deletions(-) diff --git a/gweb/gweb.c b/gweb/gweb.c index 78d4fb0517ff..4a402ccfc346 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1130,8 +1130,67 @@ static void add_header_field(struct web_session *session) } } -static void received_data_finalize(struct web_session *session) +static int map_gerror(const GError *error) { + int err; + + if (error->domain == G_CONVERT_ERROR) { + switch (error->code) { + case G_CONVERT_ERROR_NO_MEMORY: + err = -ENOMEM; + break; + case G_CONVERT_ERROR_ILLEGAL_SEQUENCE: + err = -EILSEQ; + break; + case G_CONVERT_ERROR_PARTIAL_INPUT: + err = -EBADMSG; + break; + default: + err = -EIO; + break; + } + } else if (error->domain == G_IO_CHANNEL_ERROR) { + switch (error->code) { + case G_IO_CHANNEL_ERROR_INVAL: + err = -EINVAL; + break; + case G_IO_CHANNEL_ERROR_FBIG: + err = -EFBIG; + break; + case G_IO_CHANNEL_ERROR_IO: + err = -EIO; + break; + case G_IO_CHANNEL_ERROR_ISDIR: + err = -EISDIR; + break; + case G_IO_CHANNEL_ERROR_NOSPC: + err = -ENOSPC; + break; + case G_IO_CHANNEL_ERROR_NXIO: + err = -ENXIO; + break; + case G_IO_CHANNEL_ERROR_OVERFLOW: + err = -EOVERFLOW; + break; + case G_IO_CHANNEL_ERROR_PIPE: + err = -EPIPE; + break; + default: + err = -EIO; + break; + } + } else { + err = -EIO; + } + + return err; +} + +static void received_data_finalize(struct web_session *session, + GIOStatus status, gsize bytes_available, + gsize bytes_read, const GError *error) +{ + int err = 0; const guint16 code = GWEB_HTTP_STATUS_CODE_UNKNOWN; session->transport_watch = 0; @@ -1139,7 +1198,41 @@ static void received_data_finalize(struct web_session *session) session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, 0, code); + /* Handle post-channel read errors, which could be either + * G_IO_STATUS_ERROR or G_IO_STATUS_EOF. + * + * For G_IO_STATUS_ERROR, simply attempt to map the error from + * GError, if available. + * + * For G_IO_STATUS_EOF, this could occur at the end of a nominal, + * successful get. That is, some number of headers, with or + * without a body, termiated by an expected end-of-file (EOF) + * condition. However, G_IO_STATUS_EOF can also happen as a result + * of the remote peer server unexpectedly terminating the + * connection without transferring any data at all. The only + * reasonable recovery for this case it to fail the request, + * synthesizing -ECONNRESET as the error, and to let the client + * request again. + * + * If we asked for a non-zero amount of data but received none and + * have accumulated no headers thus far, then we assume that the + * remote peer server unexpectedly closed the connection; + * otherwise, we assume it is a normal EOF closure. + */ + + if (status == G_IO_STATUS_ERROR) { + if (error != NULL) + err = map_gerror(error); + else + err = -EIO; + } else if (status == G_IO_STATUS_EOF) { + if (bytes_available > 0 && + bytes_read == 0 && + !g_web_result_has_headers(&session->result, NULL)) + err = -ECONNRESET; + } + + call_result_func(session, err, code); } static bool received_data_continue(struct web_session *session, @@ -1260,8 +1353,10 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, gpointer user_data) { struct web_session *session = user_data; + const gsize bytes_available = session->receive_space - 1; gsize bytes_read; GIOStatus status; + GError *error = NULL; /* We received some data or condition, cancel the connect timeout. */ @@ -1277,7 +1372,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, session->result.buffer = NULL; session->result.length = 0; - call_result_func(session, -EIO, GWEB_HTTP_STATUS_CODE_BAD_REQUEST); + call_result_func(session, -EIO, GWEB_HTTP_STATUS_CODE_UNKNOWN); return FALSE; } @@ -1286,16 +1381,20 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, status = g_io_channel_read_chars(channel, (gchar *) session->receive_buffer, - session->receive_space - 1, &bytes_read, NULL); + bytes_available, &bytes_read, &error); - debug(session->web, "bytes read %zu status %d", bytes_read, - status); + debug(session->web, "bytes read %zu status %d error %p", bytes_read, + status, error); /* Handle post-channel read errors, which could be either * G_IO_STATUS_ERROR or G_IO_STATUS_EOF. */ if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN) { - received_data_finalize(session); + received_data_finalize(session, status, + bytes_available, bytes_read, error); + + if (error != NULL) + g_clear_error(&error); return FALSE; } From patchwork Tue Mar 4 01:11:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999730 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B174A6EB7C for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; cv=none; b=k6DF9BZ7GtM5jonqXyC4+lIvfya7LnueVFPUQAduherjfdMp89PiUXHm8KGHwJeJ3c0SDawqpZi1e9H3nfn0EZZVUPb31rdy1XNYsI3EyYCN4ty2EkXC0DUJSUUl+j9Sxc7LLyShssfKr2DOgRBijfykNygDz2BDcdAxwDqxoaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; c=relaxed/simple; bh=qs5R7JB5PHvQNbpmDh3U23jml50Tl3iuv4oBaHA7GeM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eVFRiuXSyLACRtp+fVh9A0lGR8hZjjQH3vMGLos1mg7pA9xImfLTvWY8eAm80i8mzpZPkxE5lnSmrcBmB5WGGRsSG8rFWaLN3jj7A5hAlh8HiamPI5eZRewtRuU7U8+BGrFEehDsBVHnqt0lF9sNHhodTGJ6Mwmc62mxCFCtE5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=T/8hQ6bl; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="T/8hQ6bl" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id DA801164B57 for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 92413124F28 for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 12/22] gweb: Add documentation to 'map_gerror'. Date: Mon, 3 Mar 2025 17:11:03 -0800 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=iEOz9EaCgAx7IVywMFbcNPzXGx3AgL7YsYQhDq84H48=; b=T/8hQ6bl+P8qYXlwqp5wXS5KoZcTWnOEvIOgEX7Snb9/cHftK8qIFg8KBMinPucsIsb8Ol3XUv4dXxkk/8vSsIBMK0fcgW7Sc+SiJabM2mgF8UM1AYUa95D3LIBQ9GzQg4oa8G/GbPYwOSMvjfEw6okrZryXmrZOCrs9ElSHQCJhQTghjFUx19S503eVgbjLsXY987Z1y9YmnEwPNyxGdrpyy0nuqX+EmLsPj/TAIlGospZ+qDmzJg4Ydimg6oIeQ8r+MEYjZ4zdhltaKjMVh6Eei9OkM0QFNVAtAC+R7aFFOle0Ahlh3gwmAP/xJ6VWuIkdFyaaBXGs7YIfM4ZpiQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'map_gerror' function. --- gweb/gweb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index 4a402ccfc346..12fe682cedfb 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1130,6 +1130,20 @@ static void add_header_field(struct web_session *session) } } +/** + * @brief + * Map a glib error into the negated POSIX error domain. + * + * This attempts to map the specfied glib error into the negated + * POSIX error domain, defaulting to -EIO for unmapped domain/code + * pairs. + * + * @param[in] error A pointer to the immutable glib error to map. + * + * @returns + * A mapped glib error into the negated POSIX error domain. + * + */ static int map_gerror(const GError *error) { int err; From patchwork Tue Mar 4 01:11:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999729 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEEC47346D for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; cv=none; b=KRhL6JFshAnpqDdZ5kMyYnDQQG4ZL0AUDxKo0PNunxpCI15pSjC7M6TiOmqaTV4MpatYgfWxlie+0w6v6PwGZMG4nxJI1AN4agndqkw+zW9rRKvqKXEofpei5tusYtYc1muMJ5JKrWZmltkK/1u5le59SIwyJYRfC13kv1KvaLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050688; c=relaxed/simple; bh=BSDpCfSloqLvSHajTRfJl9+f/Sbwe3sJIRINhQGr240=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fi03Rc3AV5oy1mu3Kvla4lhx795lVzuCImbIBPkGAORqpDt2tGTBApGfgtTBcKQxs0KshSLgwV2hH9zWj4Gaq/cTiOjKZ6meRlaj0sSjRnWKVDyVWP6u9hxua6vcS8Q1wx/dkWFNqgvlp1ozEz9//TVmb2DW9KjZONk20B1XfDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=YDqwGn9B; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="YDqwGn9B" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 54729164B58 for ; Mon, 3 Mar 2025 20:11:21 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 0A891124FBC for ; Mon, 3 Mar 2025 20:11:20 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 13/22] gweb: Add documentation to 'received_data_{finalize,continue}'. Date: Mon, 3 Mar 2025 17:11:04 -0800 Message-ID: <7c22648e2f3f3138b4e44bdf462d8686917471f2.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=HaG/KMdQ7/9c30YHFESj0m55Cx83if+Mv2saGq8jdzQ=; b=YDqwGn9BQGMpHw4QxanJylmb/BWD7LaDXigJEzVvUI5B6Nd7BvbTCdJLeel7q+1tjYPG5dgcSzPUSLxatedmId8bYIDCFMmf2aICNpFp9fYm5ujKgQI+6j2tHldqlxa9Uwr0vG9IMyYyzpI2qfp+c9OZc7izlbRVtrAaXNph70pbgiVre7GoJXRZsIgOuRvBVPCO2uZabJ7kt82QVXlk+csZB8byILncBMY6Brs8FvpWQgO5WrKRTaFdMXus+GxTaLYrfRZZXHPyFjmRq8NT7U2DGVaNyoQbAjKfl4qL5uIT4+0Hpq6GSP6SJo4hyPno0Mp0qf4wIhumMGwIJjp1cw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'received_data_{finalize,continue}' functions. --- gweb/gweb.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index 12fe682cedfb..c7af3986df8f 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -1200,6 +1200,43 @@ static int map_gerror(const GError *error) return err; } +/** + * @brief + * Finalize a glib I/O channel watch received data delegation for a + * web session request. + * + * This finalizes a glib I/O channel received data failure or + * success for @a session. This assumes that @a status is either + * #G_IO_STATUS_ERROR or #G_IO_STATUS_EOF. #G_IO_STATUS_ERROR + * represents an unconditional failure completion. #G_IO_STATUS_EOF + * may represent a successful completion, if it follows one more + * prior received data transfers for @a session. However, it + * represents a failure completion if it occurs prior to the receipt + * of any @a session data. + * + * @param[in,out] session A pointer to the mutable web + * session request to finalize. + * @param[in] status The status from the prior call + * to #g_io_channel_read_chars used + * to determine how to finalize @a + * session. + * @param[in] bytes_available The number of bytes advertised + * to the prior call to + * #g_io_channel_read_chars. + * @param[in] bytes_read The number of bytes read by the + * prior call to + * #g_io_channel_read_chars. + * @param[in] error An optional pointer to the glib + * error instance associated the + * prior call to + * #g_io_channel_read_chars. + * + * @sa received_data_continue + * @sa received_data + * + * @private + * + */ static void received_data_finalize(struct web_session *session, GIOStatus status, gsize bytes_available, gsize bytes_read, const GError *error) @@ -1249,6 +1286,23 @@ static void received_data_finalize(struct web_session *session, call_result_func(session, err, code); } +/** + * @brief + * Continue a glib I/O channel watch received data delegation for a + * web session request and process the data from it. + * + * @param[in,out] session A pointer to the mutable web session + * request to continue and process + * received data for. + * @param[in] bytes_read The number of bytes read by the prior + * call to #g_io_channel_read_chars. + * + * @sa received_data_finalize + * @sa received_data + * + * @private + * + */ static bool received_data_continue(struct web_session *session, gsize bytes_read) { From patchwork Tue Mar 4 01:11:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999733 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFC3B6A33B for ; Tue, 4 Mar 2025 01:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; cv=none; b=uMQjzb5f5g+BuT66cUPRV03I+A0qFR1YcRbSTVMTn4JRJoMDI3bp1go1oq8PdJoxXJHkYguZvAnvqOhh9XlfVgvLbRYOY8uWzHyWK4dc4Ju8QYcCnzhVxMk9AVtlc6K77ZI1rLK4Thw82rlZ9CuT8ZrhruA6NE9rCc0ZmODzYE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; c=relaxed/simple; bh=w2CTuhPGjk0Fn3bB+RzLBfW4v8Rp0JrNtnj94WBFKJc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lm/3uDfBRXM3fjOadQhX+OcofX7H/NPWr8bGTONDhnOxFhntd85j1MO68vp5mgs9q9KXhi84vGIUBuF2HUJoICwq5SSiA6gM//hEpo0NtIxfnJcbgob/MqYXnOjJmY+Lpz113D0s6HWHhiNQ6e0BmL5qSaOPvovFcWajghu0CEg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=nW/6sfs5; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="nW/6sfs5" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id C150C164B59 for ; Mon, 3 Mar 2025 20:11:21 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 787BC1260D5 for ; Mon, 3 Mar 2025 20:11:21 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 14/22] gweb: Document 'struct _GWebResult'. Date: Mon, 3 Mar 2025 17:11:05 -0800 Message-ID: <2a78dc5c6e943f96271f4a49f1d0b02120167fbc.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=3v8CY/6+Dkp+b0bB9D0HK8KetED44shCDGWVZGTzjH0=; b=nW/6sfs5fqp7ublPO3PgQA7zBFpDMnfnqV0SmG7qODTHSsbi3SoMa68owwQ1Dg8WfSpgFUB3EVp8jEUVTM5toExPM+s8dKyU0n7jYwQJ7rjMCe7FQKc8PE1a/42EudTMD4D4PWhJ42aQvhTy3ZYAy7Fo4AyYYsEDFdyUVkYKmSLEyTyih1TmA0Z+HR1in+07UHlLkLQWR2pR8T5Wrys3WKVFpqDRHz+MzGebel+hFns6Wj39nHBHo6o8WalJb/Gyv/648MOr9iLZkwS13SwK5X4E98rQRxNeo9pIXen+RhY11trpJy4ddTtvJYVWp+Zz6WJBJ8KD39xG3G9SDf38sA== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the remainder of the 'struct _GWebResult' data members and to the overall structure. --- gweb/gweb.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gweb/gweb.c b/gweb/gweb.c index c7af3986df8f..050bb2d3e134 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -54,6 +54,12 @@ enum chunk_state { CHUNK_DATA, }; +/** + * The opaque structure presented to GWeb clients on received data or + * request closures. + * + * @private + */ struct _GWebResult { /** * Operating system error, if any, associated with the request. @@ -62,11 +68,38 @@ struct _GWebResult { * domain error number). */ int err; + + /** + * HTTP status code on success. + */ guint16 status; + + /** + * HTTP body content on success; otherwise, NULL. + */ const guint8 *buffer; + + /** + * HTTP body length on success; otherwise, 0. + */ gsize length; + + /** + * Boolean indicating whether the HTTP response uses HTTP/1.1 + * chunked transfer encoding. + */ bool use_chunk; + + /** + * An optional pointer to a null-terminated C string containing + * the last HTTP header name added as part of a header key/value + * pair. + */ gchar *last_key; + + /** + * HTTP headers, on success, keyed by the header name. + */ GHashTable *headers; }; From patchwork Tue Mar 4 01:11:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999734 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 338ED78F33 for ; Tue, 4 Mar 2025 01:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; cv=none; b=OpRm2Tm2u0cTj9a22XUYZ2Yp1XgiN7ykxybyKPdm6+LsCZo+gXNlIusmyNv9mQRNoFE7S89MwTScYLDjPIMzyKU3QJM5yVA8o7DLiNZp7IWc+ck5JhimzVMdkG1+V48NbP8t3DM32U0/ULh7fj9eh2OCcwS4pN47xjMJ7UeA5g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050689; c=relaxed/simple; bh=a2vYA0DwWfWhMSO0qIKXExy9Q4e8EnaKACKm0aLPgRk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ch+ZcWbwHrYSfnWyyoFED7rjEThSciNP7dV3oa2+5ebeDfM4+VnhDtwqjOKbCzVhhd2Wdy9pNJadfBw28g4xB5Eo4Wqeu3mUIppBPUViCx8XzN4qGp7vbVAra45Pztxk2uYqSOsQCKzDtEfzPKDHSqOoK2cQK3oV9Inu3uFu6oU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=A4cT/fVG; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="A4cT/fVG" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 39528164B52 for ; Mon, 3 Mar 2025 20:11:22 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id E5CEF1260D5 for ; Mon, 3 Mar 2025 20:11:21 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 15/22] wispr: Add and leverage 'portal_manage_failure_status'. Date: Mon, 3 Mar 2025 17:11:06 -0800 Message-ID: <4eb202c9799b338c737cb536c816eb4717fd984e.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=dhZsM9+IQZheZCuuGM5y51FumH1m01pXtFKzMStaNWM=; b=A4cT/fVGrkAd/tuf8/AHELQFEFYNDcr/CIhE7yf+Qoxb3BXbTkZcmvC6u7D7bNtKzfhAXBVEQrS35oQBr1qrG7vU9m66A7sR8HzVsKQCPhFLaRwYRRBN0p1c9lOBBpvb3lPwoA15x/TPKXVb5fwrQNjbF2H8zxK3Z8kSgFSlLHrnRLomslgoP7sx94gznLWsPsJ3NqoRKcKNVs7itql9Q9mwRsSTYogTqmMIzt1h+NEBQud/PQGEJ6k7B8AljCBywv+kBVhGVG8HzFON3jHxFclQ3SNTEv9DVLLujWjT94P5RKfUr0RF5sYPJ/pPjDHlUID6YSz9l1WfhnYpgZDIHw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Consolidates seven common call site patterns into a common function, reducing the parameters passed at each call site from four to two. --- src/wispr.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index 9b0e4b24a3db..fc49778fa607 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -633,6 +633,16 @@ static void wispr_portal_error(struct connman_wispr_portal_context *wp_context) wp_context->wispr_result = CONNMAN_WISPR_RESULT_FAILED; } +static void portal_manage_failure_status( + struct connman_wispr_portal_context *wp_context, + int err) +{ + struct connman_service *service = wp_context->service; + enum connman_ipconfig_type type = wp_context->type; + + wp_context->cb(service, type, false, err); +} + /** * @brief * Handle a successful "online" HTTP-based Internet reachability @@ -773,10 +783,7 @@ static void wispr_portal_request_portal( wp_context, &err); if (wp_context->request_id == 0) { - wp_context->cb(wp_context->service, - wp_context->type, - false, - err); + portal_manage_failure_status(wp_context, err); wispr_portal_error(wp_context); wispr_portal_context_unref(wp_context); } @@ -1049,24 +1056,15 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) goto done; case GWEB_HTTP_STATUS_CODE_BAD_REQUEST: - wp_context->cb(wp_context->service, - wp_context->type, - false, - -EINVAL); + portal_manage_failure_status(wp_context, -EINVAL); break; case GWEB_HTTP_STATUS_CODE_NOT_FOUND: - wp_context->cb(wp_context->service, - wp_context->type, - false, - -ENOENT); + portal_manage_failure_status(wp_context, -ENOENT); break; case GWEB_HTTP_STATUS_CODE_REQUEST_TIMEOUT: - wp_context->cb(wp_context->service, - wp_context->type, - false, - -ETIMEDOUT); + portal_manage_failure_status(wp_context, -ETIMEDOUT); break; case GWEB_HTTP_STATUS_CODE_HTTP_VERSION_NOT_SUPPORTED: @@ -1169,10 +1167,7 @@ static void proxy_callback(const char *proxy, void *user_data) if (!proxy) { wispr_log_proxy_failure(wp_context, "No valid proxy"); - wp_context->cb(wp_context->service, - wp_context->type, - false, - -EINVAL); + portal_manage_failure_status(wp_context, -EINVAL); return; } @@ -1519,7 +1514,7 @@ int __connman_wispr_start(struct connman_service *service, free_wp: DBG("err %d wp_context %p", err, wp_context); - wp_context->cb(wp_context->service, wp_context->type, false, err); + portal_manage_failure_status(wp_context, err); g_hash_table_remove(wispr_portal_hash, GINT_TO_POINTER(index)); return err; @@ -1605,10 +1600,7 @@ int __connman_wispr_cancel(struct connman_service *service, cancel_connman_wispr_portal_context(wp_context); - wp_context->cb(wp_context->service, - wp_context->type, - false, - -ECANCELED); + portal_manage_failure_status(wp_context, -ECANCELED); wispr_portal_context_unref(wp_context); From patchwork Tue Mar 4 01:11:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999735 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 338AC3BBC9 for ; Tue, 4 Mar 2025 01:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=GnGlXUJw7a9ZV1ylLbxR4nN9YfS1KTnBAAyxoMOoSC3ntUfZ7AbR6iDIOjCA1409966gK67SrY5K5WesaxpdycVlYQ5FLlb2R5oe196cZjmZjpoZQc5h2/fqf6POzSgp7HPE6ghAFIFJoVK401skSz/+yA3A0LxVd+o3OnyZ0bA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=m5qc72d+E5U/nlVvK1iWbWX8jce6UQPp+Woq5ug82Ug=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X1bjyE0aWU1N4FliKf+ZOiZm8dHlSvYDZCNZ4SehxKY296QSAT6DmB/rZSk0YRzFdUFx7Pk4DywGMZf7Kinw3ejIri+CxlXaixepMLiwFCkf7wNOphFtd+v/tT6GgGi0cWlMLyZ8ou1vcNIS3yAPRYSg5lGpTgF2/bi9uEMtiQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=AEFFrK6J; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="AEFFrK6J" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id A5790164B5A for ; Mon, 3 Mar 2025 20:11:22 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 5D0481260D5 for ; Mon, 3 Mar 2025 20:11:22 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 16/22] wispr: Refactor 'wispr_portal_web_result' to leverage 'g_web_result_get_err'. Date: Mon, 3 Mar 2025 17:11:07 -0800 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=Jf7mqV8g1VpJ7Y6ZpUGNOHiXlN41k9Qv2NfoXBIElio=; b=AEFFrK6J9abnolIWcAy33oNyIApIU44JRDYPcysnOB5Zmh/2o/Cwjq/HfNQMfN5YRpn+SJdFEw3Y/7T0WFzmgSOThMYvSf0STAHcKmZo8MK1ZLOC4rQcFfqfo6mdre1Nb3MHiV7ols55jXd4lg5l7ifWEggMkdDou+gKl/ih8QCxj3F8P3RJWbJu08OCc0oJZx+FYSXBCx+SNtZuymN2/On/MVIBtQWqb+sF2mPKF+2U+GXdX/bXvNEURvB+exiTygdKdNFodWwiWeze5VJsJh3DFiDCRX1kBRoDnR0e9lDqG/6Brx1Vodize/DeXIjpAeDT7Z2ZymwvGmmVPlYWBQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Leverages the newly-added GWeb 'g_web_result_get_err' interface to refactor 'wispr_portal_web_result' into 'wispr_portal_web_result_err' and 'wispr_portal_web_result_no_err' with the former handling non-successful POSIX error domain cases and the latter handling successful HTTP status code cases. Prior to the introduction of 'g_web_result_get_err' and this refactor, there existed a "hole" in the finalization of WISPr IPv4 and IPv6 "online" HTTP-based Internet reachability checks web request sessions that both could and did leave such checks "dangling" and non-renewing such that an expected active, default network service failover does not occur when it should. The "hole" involves an end-of-file (EOF) condition. In the normal case, there are a series of one or more data receipts for the web request as headers of the request response are fulfilled. When there is no further data to send, the final receive completes a normal EOF that leads to the successful closure of the web request, typically with HTTP 200 "OK" in the nominal success case. However, there is a second EOF case that appears to happen with a random distribution in the nginx server backing the default "online" HTTP-based Internet reachability check URLs, 'ipv[46].connman.net/online/status.html'. In that case, the nginx server appears to periodically do an unexpected and spontaneous remote connection close after the initial connection but before any data has been received. Prior to this change, all such failures hit the same WISPr error-handling block which effectively maps such a failure to the effective 'GWebResult' "null" GWEB_HTTP_STATUS_CODE_UNKNOWN status value. Unfortunately, WISPr historically had no way to distinguish this as an actual failure or success and so it lands on the case: case GWEB_HTTP_STATUS_CODE_UNKNOWN: wispr_portal_context_ref(wp_context); __connman_agent_request_browser(wp_context->service, wispr_portal_browser_reply_cb, wp_context->status_url, wp_context); which does not "bookend" the original, initiating WISPr web request and leaves the original request "dangling" and non-renewed, eventually leading to the aforementioned "hole". With this change, the second, failure EOF case will now return '-ECONNRESET' from 'g_web_result_get_err' and will be handled as a failure by 'wispr_portal_web_result_err', "bookending" the original "online" HTTP-based Internet reachability check. All of the prior HTTP status code cases are handled by 'wispr_portal_web_result_no_err'. --- src/wispr.c | 95 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/src/wispr.c b/src/wispr.c index fc49778fa607..d1d49704e5bf 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -782,6 +782,8 @@ static void wispr_portal_request_portal( wispr_route_request, wp_context, &err); + DBG("wp_context->request_id %d err %d", wp_context->request_id, err); + if (wp_context->request_id == 0) { portal_manage_failure_status(wp_context, err); wispr_portal_error(wp_context); @@ -973,38 +975,26 @@ static bool wispr_manage_message(GWebResult *result, return false; } -static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) +static void wispr_portal_web_result_err(GWebResult *result, + struct connman_wispr_portal_context *wp_context, + int err) { - struct connman_wispr_portal_context *wp_context = user_data; - const char *redirect = NULL; - const guint8 *chunk = NULL; - const char *str = NULL; - guint16 status; - gsize length; - - DBG(""); - - if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) { - g_web_result_get_chunk(result, &chunk, &length); - - if (length > 0) { - g_web_parser_feed_data(wp_context->wispr_parser, - chunk, length); - /* read more data */ - return true; - } + portal_manage_failure_status(wp_context, err); - g_web_parser_end_data(wp_context->wispr_parser); + free_wispr_routes(wp_context); + wp_context->request_id = 0; +} - if (wp_context->wispr_msg.message_type >= 0) { - if (wispr_manage_message(result, wp_context)) - goto done; - } - } +static void wispr_portal_web_result_no_err(GWebResult *result, + struct connman_wispr_portal_context *wp_context) +{ + guint16 status; + const char *str = NULL; + const char *redirect = NULL; status = g_web_result_get_status(result); - DBG("status: %03u", status); + connman_info("status: %03u", status); switch (status) { case GWEB_HTTP_STATUS_CODE_UNKNOWN: @@ -1073,12 +1063,64 @@ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) wispr_portal_browser_reply_cb, wp_context->status_url, wp_context); break; + default: break; } free_wispr_routes(wp_context); wp_context->request_id = 0; + +done: + return; +} + +static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) +{ + struct connman_wispr_portal_context *wp_context = user_data; + const guint8 *chunk = NULL; + int err; + gsize length; + + DBG("result %p user_data %p wispr_result %d", + result, user_data, wp_context->wispr_result); + + if (wp_context->wispr_result != CONNMAN_WISPR_RESULT_ONLINE) { + g_web_result_get_chunk(result, &chunk, &length); + + DBG("length %zu", length); + + if (length > 0) { + g_web_parser_feed_data(wp_context->wispr_parser, + chunk, length); + /* read more data */ + return true; + } + + g_web_parser_end_data(wp_context->wispr_parser); + + DBG("wp_context->wispr_msg.message_type %d", wp_context->wispr_msg.message_type); + + if (wp_context->wispr_msg.message_type >= 0) { + if (wispr_manage_message(result, wp_context)) + goto done; + } + } + + /* Check whether there was an operating system error while + * processing the web request associated with the "online" + * HTTP-based Internet reachability check. + */ + + err = g_web_result_get_err(result); + + DBG("err %d", err); + + if (err < 0) + wispr_portal_web_result_err(result, wp_context, err); + else + wispr_portal_web_result_no_err(result, wp_context); + done: wp_context->wispr_msg.message_type = -1; @@ -1088,6 +1130,7 @@ done: * maintaining a weak reference to it. */ wispr_portal_context_unref(wp_context); + return false; } From patchwork Tue Mar 4 01:11:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999736 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52AA878F4C for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=Udwn9laxcJUZGOtwph9Prf3NpJuN86ailwxCzo27eZfEHx+WifX4i28zrt2VyjkFyeDMc07IaziX6aYppaz5EXqcvYqVxdLzg8E1b/a7e+ouVIdfizFfkFJTwzyOsaMQHZ4OVFj2jrcAECF89GOTofTaAylpEzu6x0fsWRM6Zzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=U3KYwO1Rtcp8+xN+QuOdp/29DrtAC3bS3WGl/lIsINI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqZjX3yslTozW/loQ/ppb9CeZB5NfptAy0Vx4OYCBfbchJwuRb6bbdfx8S4Ydbs0MdhqcQh17/sHqRi1fiGdfn0zz+1yHVln/Pais1Q5IGSqSz1v6aVxLxHESdmIs7EXLgXTtRoxUpbU6SEnzgXawmJt7YlxC7Z1XybWG4rLEWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=RabdN2ay; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="RabdN2ay" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 1DDB3164B5B for ; Mon, 3 Mar 2025 20:11:23 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id C9C34124FD3 for ; Mon, 3 Mar 2025 20:11:22 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 17/22] wispr: Document 'portal_manage_failure_status'. Date: Mon, 3 Mar 2025 17:11:08 -0800 Message-ID: <87d043db5ae7bb0c55ae4c00a24ca8dd813ca7cc.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=k5J1l7mFN93UAHnz15FMHUZ4cJNt8weXt4+Lpc6tgdM=; b=RabdN2ayTSnnbKGV2zAG7dMhKpsu8KEPwD7EDAXa9wv2RldaEwf/qpnMgbNd7DLE7A1Pqt9zVf1Z1zfEIh0YMaMrK2mR5v2JI6eULDtduV44TQAMXDCBrFGPJU5CelKeoYjZACMbQp+uNoRcydDfzwkyZFLDNJ60I4OhGRxU9DeQXVhRHbBQSaicvDWDhQTNbGv92+qB1+1k/pNARjH9Ed40MsiWCdKv96pN8TMwEf9rMk34pMMH9t2sCDbuGpF/4jpPcIQjy2bV37y1TD4yCk5+n2h0t++K8FI/9f708xNRccf8O7n3pvKP6dlRBOQ7e3EH1Z2WO2nSSJ7fzW5Wsw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'portal_manage_failure_status' function. --- src/wispr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/wispr.c b/src/wispr.c index d1d49704e5bf..83422c96b50d 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -633,6 +633,34 @@ static void wispr_portal_error(struct connman_wispr_portal_context *wp_context) wp_context->wispr_result = CONNMAN_WISPR_RESULT_FAILED; } +/** + * @brief + * Handle an unsuccessful "online" HTTP-based Internet reachability + * check. + * + * This handles an unsuccessful (that is, either completed with a + * non-successful operating system error or with a non-HTTP 200 "OK" + * status code) "online" HTTP-based Internet reachability check + * previously-initiated with #__connman_wispr_start. + * + * @param[in,out] wp_context A pointer to the mutable WISPr portal + * detection context associated with the + * unsuccessful "online" HTTP-based + * Internet reachability check this is + * handling. + * @param[in] err The negated POSIX domain error + * associated with the unsuccessful + * "online" HTTP-based Internet + * reachability check. + * + * @sa portal_manage_success_status + * @sa wispr_portal_web_result_no_err + * @sa wispr_portal_web_result_err + * @sa wispr_portal_web_result + * + * @private + * + */ static void portal_manage_failure_status( struct connman_wispr_portal_context *wp_context, int err) From patchwork Tue Mar 4 01:11:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999739 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52A6678F4A for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=hRekr6+inV8E0VlLqemmsMf7Y6NkJdpGe10Qi9o2vQR0YzI1fT7DrrfsDsw9fd53ueRYbh/KRE2FCRiKWnGCJ4xij/rn/Gaz9zAZZggHSuDConvtUf8m438yWiZaB7aexox2VoxFtSVrIGGU/nS1qgGOL06ssJuSrcgUHr6mVNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=XX1T95mwvWuXbs10OZ2tWgGrnXoyIQOpfNIkkuz1iCY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f4l21/ejkHBf8qCmc07ppY6QNb7l3g/mxthkLtbwnuNfp8WpmP1RtXLQd7Y5PQPXHSCeGo4GYYRpG7NQl7JlNYOq45SpnQI+J4/G+C+XpvNpEswvYLIx/xUq5p7qiOluz7puKNKePKctxm+qVKnxRt3QnzoxXMeLxD1n2f8z/A4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=J1ii+pl/; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="J1ii+pl/" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 89791164B5C for ; Mon, 3 Mar 2025 20:11:23 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 416F0124FD3 for ; Mon, 3 Mar 2025 20:11:23 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 18/22] wispr: Document 'wispr_portal_web_result_err'. Date: Mon, 3 Mar 2025 17:11:09 -0800 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=aHZZKGleacv82JkKdvz7Ahq3dLEI8hESkEDRHkwaExc=; b=J1ii+pl/wy8htKrJoY1TT+oIcE/SQKESIcmNjI48qKKoUs/PKkw3ru7itSLtNvy5Z794xntXzF6WTXQrNMleoCMoZktyelqfE9W00cRS2ni78UUFfslEgi8L9//QMslJvLBJfKIrMcH0gnArJuZ1PjOk8th8gxGZGRR3Oe36eMwqi23LhBfJY734ycBESSJ5ZUcJtxHBg/1Fl+qRvpld20RIwqnIDCVAj67uvGsT5nBQmXjeg1XCR4eLnKYlKnHYKvUmSPdLL/QegjKQge8kb2UbgdwqzpQbZztjUzDZBuZahyFJHwYkIG1OuHLNpCuNd3tkYB9rASQLlc+OQQw/fg== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'wispr_portal_web_result_err' function. --- src/wispr.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/wispr.c b/src/wispr.c index 83422c96b50d..0a29303116eb 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -1003,6 +1003,29 @@ static bool wispr_manage_message(GWebResult *result, return false; } +/** + * @brief + * Handle closure and finalization of a web request associated with + * an unsuccessful "online" HTTP-based Internet reachability check. + * + * @param[in] result A pointer to the mutable web request + * result being finalized. + * @param[in,out] wp_context A pointer to the mutable WISPr portal + * detection context associated with the + * unsuccessful "online" HTTP-based + * Internet reachability check this is + * finalizing. + * @param[in] err The negated POSIX domain error + * associated with the unsuccessful + * "online" HTTP-based Internet + * reachability check. + * + * @sa wispr_portal_web_result + * @sa wispr_portal_web_result_no_err + * + * @private + * + */ static void wispr_portal_web_result_err(GWebResult *result, struct connman_wispr_portal_context *wp_context, int err) From patchwork Tue Mar 4 01:11:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999740 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6402278F59 for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=bj6hUEcRMKmPAyK6tglIQwzsWrHtQbBH7+75lPi5fn25oqL3bYn+OFQV/xaBZDpBtEnAwKYWaVtdfjJ40eAXSWe9CtKSyNjB8qhAf2Uyh7J2hTJTyYatjddTtkb87KZXoqnNTyCy3RkIhzzYtsSW2/T82gEKI7jl/5DFJxt2zP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=odnLORuzSz53Yv+gVZyQWhDL1a0anUDWkbDoNqjAbIA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k0fZTUcVhXvZWeXbi0674iNSXItAZ5CJwMoL4nHZmXhp/HP69Ng9BW60Hh6c9AcnVwiwMdNMgI0hyeUTPWi8MrA+AuER6a7Q/41EZsb6n2RSBeGfKnA6Iur+MtTAWCRF4y9Z8gRAboi4f/SOfORK8KvTyLIHFUoTP3L896y7Jig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=mjge1j7+; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="mjge1j7+" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 017DF164B5D for ; Mon, 3 Mar 2025 20:11:24 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id ACFC2124FD3 for ; Mon, 3 Mar 2025 20:11:23 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 19/22] wispr: Document 'wispr_portal_web_result_no_err'. Date: Mon, 3 Mar 2025 17:11:10 -0800 Message-ID: <440d5f9ab1612ac850e5a6d9a4b485e3c49d097d.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=6rM4L/QiLHjyyjDPcx84RyKuB0OvHA7ofQO/OSzRbSE=; b=mjge1j7+PVSUWJRgZt6Yb6WPpmJaJIzvIUjI0dR7fL8INevVPtg4dAa0vStLRU2uSBV7+SWB7eT9AWiiwN20d/5OoPBvGByV3yhzqoXzqvzrGnWJ0MRwZguyewTFM3UBlVe62M0uqiwtyFC2hwLA516SrSxYv8sWqVNossDqzexXPGgG6IlzwiKH4K6YHfOfKsm3QBy8oXSgbXveqcQVWTPD5RvtyZdNLzDqAwj7T/6qzB3JvkcWwGaJVBsuEB2bcOQ91Y3zqnkLPPgWCfCHQTod9cG/MO1CgN6ismRXr+v/0Zjs+i4LAcYsbktr2pHPsVIXuGDNFKRCr/JFLlLe6A== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'wispr_portal_web_result_no_err' function. --- src/wispr.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/wispr.c b/src/wispr.c index 0a29303116eb..004227d5f1c7 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -1036,6 +1036,25 @@ static void wispr_portal_web_result_err(GWebResult *result, wp_context->request_id = 0; } +/** + * @brief + * Handle closure and finalization of a web request associated with + * a successful "online" HTTP-based Internet reachability check. + * + * @param[in] result A pointer to the mutable web request + * result being finalized. + * @param[in,out] wp_context A pointer to the mutable WISPr portal + * detection context associated with the + * successful "online" HTTP-based + * Internet reachability check this is + * finalizing. + * + * @sa wispr_portal_web_result + * @sa wispr_portal_web_result_no_err + * + * @private + * + */ static void wispr_portal_web_result_no_err(GWebResult *result, struct connman_wispr_portal_context *wp_context) { From patchwork Tue Mar 4 01:11:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999741 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6184678F54 for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050691; cv=none; b=VvOsN0oYCm/mr821BFPKtaH0HzT23uvUIk6Zk3gtfuQ7bQ3jzdZhhS8W02RvmXx1evYZLblSdu6wIJ58L9NPjFWrc+F0U3rberC/7m0Kyev8B1ENAgUFUm8vkYm9bo69nxEr/FcIt6A50D8gtr9zyopOblZVf3iiN59kVynKSVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050691; c=relaxed/simple; bh=YbAUPjldnLPUCARNckCZm0n5v+Lyah5w5BhUerVg3+g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Usbk4/MzXDpoLuwNjK1EroJpqEXAbMDMezyjacdpk8R1NHpyVyZ5uxkg755vVk6M3MFe57IqOq5t76O/ljU5iqPuFUs4RXEkQrTiYdr9PDDLcTV3RlY50wlMu6/5y0NT25Zxlk6NMflgjJ5c8geA7O1lpfInvHWn8f2uKenVej8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=rpboBhWs; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="rpboBhWs" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 6E261164B5E for ; Mon, 3 Mar 2025 20:11:24 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 25129124FD3 for ; Mon, 3 Mar 2025 20:11:24 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 20/22] wispr: Document 'wispr_portal_web_result'. Date: Mon, 3 Mar 2025 17:11:11 -0800 Message-ID: <969196ef7e20566d13ce4b04dc29709f8d0dd020.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=1CIgFa4WJtqIgDXAXN2a7UnSOHe3saxlzlh81eJ1oVA=; b=rpboBhWsWoKZRC7j+tfR7AZzea7jcWPZWnl0Yi06CNb18tEUNTsM2nm9nHZ4HQKthkX+DA6TtWMOD+2KXa7dU0zIDyCF7p4nWvEpO9sQ7XhEDDJEG0eDkCRaTtiUs+1U3zivR1gUALV7HgphvTeu5LoKpJEgfOhO0678Nhvf2IbeNS1eNhpyM1v3X0Wkw1egY3DR4hXxf0Mo7Hs0CgQTjVO8nFhckZcesFZVYfFgb/W7mB0D9w9KA6S+cGqRkpdLy8zenys++U9lL3HTCiRBaswzMjSfzTctXzZt3YixsonmCIdkLs/B58Iy8SmvxGX0TLuQ+93Tf5cpxaCZ1CG4cQ== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Add documentation to the 'wispr_portal_web_result' function. --- src/wispr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/wispr.c b/src/wispr.c index 004227d5f1c7..4abb8f071352 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -1145,6 +1145,33 @@ done: return; } +/** + * @brief + * Handle the receipt of new data and the potential closure and + * finalization of a web request. + * + * This handles the receipt of new data associated with @a result and + * the potential closure and finalization of it, if appropriate. + * + * @param[in] result A pointer to the mutable web request + * result with data to process or to be + * finalized. + * @param[in,out] user_data A pointer to the mutable WISPr portal + * detection context associated with the + * "online" HTTP-based Internet + * reachability check this is finalizing. + * + * @returns + * True if web request should wait for and process further data; + * otherwise, false. + * + * @sa wispr_portal_web_result_err + * @sa wispr_portal_web_result_no_err + * @sa wispr_manage_message + * + * @private + * + */ static bool wispr_portal_web_result(GWebResult *result, gpointer user_data) { struct connman_wispr_portal_context *wp_context = user_data; From patchwork Tue Mar 4 01:11:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999737 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B15FA86337 for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=QidC7es86zgU+8zJcB/VumiDcHGt/525WsjV08qePPMwJkcrjLS4xjMXIx0Qjq4mU6ggrKGz4T7XUKM/30rbDQrSnO/79ekPPjA6e4T3bg90iMw/xkBZNvAQnkQrZLT3jLXuJYmdkGAy3TnoIJ+NmXbRTH0KUeKwAIS/ysAp6Bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=DdMIxGVqO/dUphThZE8HzMbcWm40PUUlhhVyN/krUd0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOrHAuCqv9MMMmAiQueHdwvw7ZczPHtzVnYwuYLNKWHP581UT2BO84bXN6C8pJWlhCb/vviug5RV/udqeAHyST6cBj2R5ZNWEAvC24uAWM2Rhfubkk1qauvfrq3FipOHTRM5z7sBMM29CZdi5kJ2iCsSXBLpi5M4dfd36d7sD4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=tZvlY9a9; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="tZvlY9a9" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id E3529164B5F for ; Mon, 3 Mar 2025 20:11:24 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 91CE0124FD3 for ; Mon, 3 Mar 2025 20:11:24 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 21/22] wispr: Fix documentation typo in 'portal_manage_success_status'. Date: Mon, 3 Mar 2025 17:11:12 -0800 Message-ID: <9bec40acf7e63c782fd8d7159eb0d9297a8bfb1b.1741050622.git.gerickson@nuovations.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=fu/ivN0hPQqSvO2dvECmWf4vSoj9SvDa9g/bGMwu00w=; b=tZvlY9a9wSbvmSYpZIu6qxHB5c/ABSBPkOGLTdDIIP+wpaQIF/SS+M7FdsG1JbYRsnNqCd/i5dV5xYGSiPUyfvWAZXvabF48PWLxP2BhdlbEf2IsYnuw08CyGKj/3cGyQUUE4xFLvsYwcET2RTSXPOQi7Yeik3or6123YliRfHVSzcWHWBoArprBCoffwH7Y4XfiI26i3kj2orMDF3e32OSLjGOSnGr4Vx9wV6XtU+huFpLPy0ZGztHIu8QYjmsEmQ157+BtDNFfMNXi3/p46Xbyf8pamE6IlcR2BS6GNGrhwWVu5EAjXwN0Uh1IZwTpWY2JGdt0zHz4DSyPNboM2A== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 Fix a documentation typo in the 'wp_context' parameter for 'portal_manage_success_status'. --- src/wispr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wispr.c b/src/wispr.c index 4abb8f071352..49801b015e30 100644 --- a/src/wispr.c +++ b/src/wispr.c @@ -685,7 +685,7 @@ static void portal_manage_failure_status( * Internet reachability check this is * handling. * @param[in,out] wp_context A pointer to the mutable WISPr portal - * detection context associated the + * detection context associated with the * successful "online" HTTP-based * Internet reachability check this is * handling. From patchwork Tue Mar 4 01:11:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Erickson X-Patchwork-Id: 13999738 Received: from mail5.g24.pair.com (mail5.g24.pair.com [66.39.139.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B352386338 for ; Tue, 4 Mar 2025 01:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.39.139.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; cv=none; b=POWsFFkLshWVmxggpyfFO+Bdt72sPiN+bi3K4DmUDgVdnmr+U3LEWU0tU2CmymHxlQLbtJfVZTwxahSQ0W41RtnXBv44wtQfVHvMpXV5GqKux9aIxFJNO/msjkr0i26CbF92fbIdXDjYAX+iJ+Zm9juc6OstVeM/l7Yi3rtiVzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741050690; c=relaxed/simple; bh=S0IoI8cW8osAWztK89NCeIuGZOYZXpRC44vzGmqg3hw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W/6rdhjoDozzGwWFHf+THu8ztDSVGyGkyutlU1vv+aNu65LC8wdVi44G+QsZWIAJocJrHJC/X+1emhgf6Ueg7+8zxN6CyaXCWj1RakiJN20H4qkv1CC5N7/xjUIPaPBjROO9QMb3DOZpyOUkPYA6V/4xwcFOty1etZ709RBj9hc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com; spf=pass smtp.mailfrom=nuovations.com; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b=IDuaZyb7; arc=none smtp.client-ip=66.39.139.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nuovations.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nuovations.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nuovations.com header.i=@nuovations.com header.b="IDuaZyb7" Received: from mail5.g24.pair.com (localhost [127.0.0.1]) by mail5.g24.pair.com (Postfix) with ESMTP id 5B7F8164B23 for ; Mon, 3 Mar 2025 20:11:25 -0500 (EST) Received: from localhost.localdomain (c-73-202-63-31.hsd1.ca.comcast.net [73.202.63.31]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail5.g24.pair.com (Postfix) with ESMTPSA id 12E90124FD3 for ; Mon, 3 Mar 2025 20:11:25 -0500 (EST) From: Grant Erickson To: connman@lists.linux.dev Subject: [PATCH 22/22] service: Capture and propagate '__connman_wispr_start' return status. Date: Mon, 3 Mar 2025 17:11:13 -0800 Message-ID: X-Mailer: git-send-email 2.45.0 In-Reply-To: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> References: <099f9cd55983495c71a47a68f402720c6b3c4cab.1741050622.git.gerickson@nuovations.com> Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuovations.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=pair-202401062137; bh=JzuyPr/g95tGKoZQCm7eAGXm0UDoCaMEAA5YfTq7iZI=; b=IDuaZyb7uhcj2IZvNu55E0cYApKVN8oHsMJWeoJxJKsan/S59aTGK3RuMA0Xm8MM2Enko1bqa+nan+y4YDQ+2RCsnywz5J5Uoe5N1DvYBDRctZK5H/nFbZ3e0EcEvCb3n6tI6EuODN9aQmgasNS0wVqs6mOmlLSDllfxH+q4QEQJRGzxOoL4HWD8of9+AOXThMy/w0QI9IM6t5A9OtdR8WwMG0CdJIfAMrGzmAd4EyIqG8ltdIYNWi1PHUl81toeXgpI+cKdd3AjS9VWqYPUgtuOOjwaEzVEPvQn3iWobxnf+gB3WlhrLjQgAbYaRsYCmYOotBU6kp3AVZuYE1CAiw== X-Scanned-By: mailmunge 3.10 on 66.39.139.36 '__connman_wispr_start' has a number of early failure conditions before the call closure becomes asynchronous. Capture the return status from '__connman_wispr_start' in '__connman_service_wispr_start' and propagate it forward, ensuring that 'online_check_active_set' is NOT called in the failure case. --- src/service.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/service.c b/src/service.c index 0cfb516016b5..48a7d1f72367 100644 --- a/src/service.c +++ b/src/service.c @@ -4003,6 +4003,8 @@ static int start_online_check_if_connected(struct connman_service *service) int __connman_service_wispr_start(struct connman_service *service, enum connman_ipconfig_type type) { + int err; + DBG("service %p (%s) type %d (%s)", service, connman_service_get_identifier(service), @@ -4034,14 +4036,17 @@ int __connman_service_wispr_start(struct connman_service *service, service->online_check_state_ipv6.interval = online_check_initial_interval; - __connman_wispr_start(service, type, + err = __connman_wispr_start(service, type, online_check_connect_timeout_ms, complete_online_check); + if (err < 0) + goto done; /* Mark the online check state as active. */ online_check_active_set(service, type); - return 0; +done: + return err; } /**