From patchwork Sun Nov 14 17:27:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=Eqpew7TW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::538; helo=mail-ed1-x538.google.com; envelope-from=swupdate+bncbcxploxj6ikrbluoywgamgqevynapzy@googlegroups.com; receiver=) Received: from mail-ed1-x538.google.com (mail-ed1-x538.google.com [IPv6:2a00:1450:4864:20::538]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HsfRj3bkNz9sWJ for ; Mon, 15 Nov 2021 04:28:17 +1100 (AEDT) Received: by mail-ed1-x538.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968sf828715eds.23 for ; Sun, 14 Nov 2021 09:28:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910894; cv=pass; d=google.com; s=arc-20160816; b=Up3xKbMsA1sc3bKjoCjpWZPsGG5XnflGVvZEHm6Jq1y3GmnaGNcSsGMGEdikqE2MBn sLuQVR/IJI7vaFbNhwHYnnBAoJtSa0oN6WQ+S2n1Kav0AF1znDr5r5SQu1UAPsiYv2Ln v4IIS/ixZ5DVs/NYBav64zN39VwZssXkXOuk+dK4QXlfxUKQx0heZR1KLAvf5U+CNRlb EOekauchhEKiuWzDvpdyrtM3iIJ3p/cm9kM5yM01vNyKa6jjDrPCi3OEv6kRSw0ajTB3 yHFhhrDD+Qd5YBPYzjmAEL/dxnzWmSf6KKMwEODOcUwEpUmuFyo8O1//1qMqrf39jGfC i40Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=UGbwtH9y+k8ypLr0KGDtz5TkvGIySJHzvNTrKh61mBRvRPYRcWJFOVJ4gq+H8mfETp jUOSz7btg+uVNTDzDh2yaboCt3Y0e/hjMl6jeklQb1z9Sw7/F3+1Np5sI6cp0d9edias 8Vs7+AqZ3+lXhr9dq4mSESJKvkTtZNNkZOTYY60jib6Cqo3KL2Bfy+qyrkDvGDCLYivU dtJPuwCQpvw3Q85UVHZp/ThvkzXaGnMahgZqXGXuI5vV8yBR9cCt7sIcaaSJBAPQmFT0 e1P9xFSod6PBpGg1dQJO46Nxs6d+NLvTmAEcdKfeAbf+gFUNJd4R2eLzzn2PmMXy+5pe /hPg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=Eqpew7TWsvdJDl45O001QK0DT+O+nTB3H3GPFG67NQKeShq8ZO2f6p6Ay4rBBVsKzE dKkHRH/wyk3PFzi/RJUE+TnzWOwyJUa/ojeV/4KLwgOD3E11rlMzRiuYPataUWC6fYom yFekkh2VAD/zlcmADEQ6W7kTRShrya6F+yzxiGXyRiUql9TZAP/nbW+Oz+3Bu2sSMLon VhlC6yoeQTRSryU5JZXgSqxg613v7HOl1NnF7e94LRJDmb5bGnC7LbtlAIVSmnJILbT5 GFeWvQ8/ERHyFdPeIgYgaQvtFCJIZaNKXurbtZHDGIeOu1KOxussAIkN6urDqu/V+uyE mnBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=r98LOOOl8AqFPY5tAV19dypxEujkZp3Z22M3qzThLRO67uuVjcNhvtBq3vvnPWsgMy 80+f0+/TrkbEcNgasqbgcKcb9S2YoBBUWfLJCr+6tQOEbFh3eEWi87Hw6vOdNjJseouD 7LP+ubUTAXIGBFiMNgKFVWdhwoSIbeyKqcHDMrobjV1gSRAFSCTsHuUt/VnMqaA2/OYP JrvR4l0OrB4KYDEq20VC/qYZnw3ZAs1QH4dcnJ6BvMjrXN4utgjbwQNprFGtuW8ek2Va pwa5U7lwo1tpNGEOmi0uag9DjUHRo2aAXIQnvdJ1xzjQgfulT3+HiZihHhPTbkzPuDPz ulhA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530fLdlttQlG94IEB+nwqHBsBdw4675QiV0gSdCsyNQjdjy3ybI2 e95RKKPxjuRADj0uY7pY2XA= X-Google-Smtp-Source: ABdhPJzvoH4NtqaPuL/jrwQjvPlBd75qY6XKpS0if/rKSHTswceLtTHhDLiVX5feeZ3BFx+TuXoTjA== X-Received: by 2002:a17:907:6da2:: with SMTP id sb34mr41874619ejc.509.1636910894750; Sun, 14 Nov 2021 09:28:14 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:1484:: with SMTP id x4ls4641135ejc.1.gmail; Sun, 14 Nov 2021 09:28:13 -0800 (PST) X-Received: by 2002:a17:907:6291:: with SMTP id nd17mr41170374ejc.194.1636910893827; Sun, 14 Nov 2021 09:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910893; cv=none; d=google.com; s=arc-20160816; b=vKsXIGSdbv2JgyH78Ux1vjqjcX04F9gotgfowKM6/q/U+1lsR9hnRItPyQTsJAOqvW WKvcN5ZOBXcuXRiT51JnaPOadodE7Qv5JhQF6DRp3ybcMUgp5WGAmFJJ5ayRytAfiPxa DVCOkQmxMAUJLEChDLZRTqn7FKs7mbk1n9ZNzWM4qmj+v9dyzW1taMp1AZkMrSLYr+hg ZDul5TJRB9XudUn0ckdG8eRrzvxrUzJOPQ5GspY8BcxoA8vfTAIzWVP9LhsqKAFxxTbt rUC8OwrOJh+Z2P5HFeWmJmbuMN/XUZrHgw40CwtPakARFjGH+eGxyQlupjXur/n1H0hy zPoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Fw35yH7hIdcsDXzUM1dUpsrsHTcUX5KOT43Xod/EDP4=; b=xqw53cKoOMLl8IAxkNGGueVJy9YHrJzuzPftdDdPTWhuxxZKe0TdZ+oA2f9V5hJlk5 n6PzoPmkImSuhm3fJMA1HrA+7atEFPG0Po+tkmDT5S1TGup9SZGDMJIoKhrC1HBgFUUB 27VoiTb+eRE/HS5k15rcbVmaWxjD/t7j+SNUDQCqohLIDSGlzVKRkW0AaowYirSYdX0T CZOf36AJAxknnrQcpOPomWfayMxpz32uaDDKCjG/6IO3aW4VZxIMq3aSIw/GBlfE7IJG xwETvMmaW+E8bUblmAoz3Lzkjc9Be9RqxhuPCB4GqgwlkkhxLDJZiygTBqq0SLZg1ROR R6hg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id w5si817908ede.3.2021.11.14.09.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:13 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRd4FTgz1qwdP; Sun, 14 Nov 2021 18:28:13 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRd47wLz1qqkB; Sun, 14 Nov 2021 18:28:13 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id nC_vittETvc9; Sun, 14 Nov 2021 18:28:12 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Sun, 14 Nov 2021 18:28:12 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 5532E4540853; Sun, 14 Nov 2021 18:28:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3T2hCkHAR7_o; Sun, 14 Nov 2021 18:28:09 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id CB7EF4542727; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 15/36] curl: change signature of write data callback Date: Sun, 14 Nov 2021 18:27:12 +0100 Message-Id: <20211114172733.71602-16-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , The "checkdwl" callback is used up now only by the Hawkbit backend to check if there is a cancel request on the server. It is called by the curl WRITEFUNCTION callback, but the callback in channel_curl.c changes the signature and does not send parameters to checkdwl. Rename checkdwl in a more generic "dwlwrdata" and pass all parameters foreseen by Curl for the callback. This allows to get access to the incoming stream and the channel can be used in other cases without sending data to to installer. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 6 ++++-- include/channel_curl.h | 3 ++- suricatta/server_general.c | 2 +- suricatta/server_hawkbit.c | 17 ++++++++++------- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 287f827..74f9d48 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -191,8 +191,10 @@ size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, return 0; } - if (data->channel_data->checkdwl && data->channel_data->checkdwl()) - return 0; + if (data->channel_data->dwlwrdata) { + return data->channel_data->dwlwrdata(streamdata, size, nmemb, data->channel_data); + } + /* * Now check if there is a callback from the server * during the download diff --git a/include/channel_curl.h b/include/channel_curl.h index 8ecaf59..49d5242 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -68,7 +68,8 @@ typedef struct { bool nocheckanswer; long http_response_code; bool nofollow; - int (*checkdwl)(void); + size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb, + void *data); struct swupdate_digest *dgst; char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1]; sourcetype source; diff --git a/suricatta/server_general.c b/suricatta/server_general.c index d19a3e6..7da3c84 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -545,7 +545,7 @@ server_op_res_t server_install_update(void) channel_data.nofollow = false; channel_data.nocheckanswer = false; - channel_data.checkdwl = NULL; + channel_data.dwlwrdata = NULL; channel_data.url = strdup(url); diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index dbce9a3..aa4d9a4 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -666,12 +666,15 @@ cleanup: return result; } -static int server_check_during_dwl(void) +static size_t server_check_during_dwl(char __attribute__ ((__unused__)) *streamdata, + size_t size, + size_t nmemb, + void __attribute__ ((__unused__)) *data) { struct timeval now; channel_data_t channel_data = channel_data_defaults; int action_id; - int ret = 0; + int ret = size * nmemb; const char *update_action; server_get_current_time(&now); @@ -683,7 +686,7 @@ static int server_check_during_dwl(void) * was requested */ if ((now.tv_sec - server_time.tv_sec) < ((int)server_get_polling_interval())) - return 0; + return ret; /* Update current server time */ server_time = now; @@ -700,7 +703,7 @@ static int server_check_during_dwl(void) * go on downloading */ free(channel); - return 0; + return ret; } /* @@ -711,13 +714,13 @@ static int server_check_during_dwl(void) if (result == SERVER_UPDATE_CANCELED) { /* Mark that an update was cancelled by the server */ server_hawkbit.cancelDuringUpdate = true; - ret = -1; + ret = 0; } update_action = json_get_deployment_update_action(channel_data.json_reply); /* if the deployment is skipped then stop downloading */ if (update_action == deployment_update_action.skip) - ret = -1; + ret = 0; check_action_changed(action_id, update_action); @@ -1161,7 +1164,7 @@ server_op_res_t server_process_update_artifact(int action_id, goto cleanup_loop; } - channel_data.checkdwl = server_check_during_dwl; + channel_data.dwlwrdata = server_check_during_dwl; /* * There is no authorizytion token when file is loaded, because SWU