From patchwork Thu Jan 11 15:52:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1885702 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=LpYyru/2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13b; helo=mail-lf1-x13b.google.com; envelope-from=swupdate+bncbaabbu45qcwqmgqemdicnuq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13b.google.com (mail-lf1-x13b.google.com [IPv6:2a00:1450:4864:20::13b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T9q211v9xz1yPm for ; Fri, 12 Jan 2024 02:52:56 +1100 (AEDT) Received: by mail-lf1-x13b.google.com with SMTP id 2adb3069b0e04-50e69fc4574sf4379790e87.3 for ; Thu, 11 Jan 2024 07:52:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704988373; cv=pass; d=google.com; s=arc-20160816; b=I8xyzMxW1X0IKnxDo8ElfQHKSxjU9vhGTXo1M9fA9Vm0dRHzbd6wJYcb8ZV2+hzJsO XCRnWM0BM4lnbJexGblwgZFdoo6760F6cXPRqRZtNpYaLNTzqVnem7xYz9rnVk3crtvP pGfKkZTGzbAzkUVxG+w3DahNsLSUXLS46qInEZPzKyl7nrMMet8Ode1I4OVMGRFBbn+/ EqLhax1H+KU5ipcaUDhY9XPNpz2aAx6XBTJxuu7BYOFslyChca176Sk/WkpdmYn8Z8YU Z2cYSVRBDZW3EKTTJp9xyJ8XA58STQERw2ub64HKxNkr7540LucPAe0Bca1zyVxsMEav +u5w== 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:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=UOPot442UicpIvzFy/3DUpLZfqiliuk2E7eDZ6zcPbM=; fh=BeBIh3RcaIvLvchNldgBWZyKgRnQIUIPJvMX5Pb5emE=; b=nIAbt23AqVHO0leYLthy5MhGSU8LvnwNaY63afUw9dfG0OHykd0SzoZqNknXzPkiaq cL4RMnpOFaqhZBVSL/tySU/mub5oSVKp5S/Tn6906Zn1p9Zdwxhxf113kLF9wOFyY5UB PkAQG3K1J2ANUTWEPMBEzkseLslTMdv2rKQOfOjuNf83bPW7ZjozAxo7FcH6tX4Cnt8G 8yeAMX8+rweJ5mq3hZ0rWPav/vZPbmffsHD/kVcAKmV/alrfFSlJV6LTpWwts26EukMK ucEUfu+Bq3w2ivh+Fq+iTyM0GCs/zOlIidmf07eOaJm3ZnUHdLzg0zZdp0hhDvUYFdnL zFHQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1704988373; x=1705593173; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=UOPot442UicpIvzFy/3DUpLZfqiliuk2E7eDZ6zcPbM=; b=LpYyru/2oDjcAO2gYRHChsuES5AuirrqebqSbTNh2x1ZikT+OZKqSzuIsbRdcJKBxh bULG/+Tvqa2OeiyvDAMZiOcjUJC+JBQrR1SrGLv39cBo33+bhsinRCu2hFqf8+anBXl7 hvDJntWlaEy1GxpPUXSBxeu4frSME4lS+q7trmmwdiS5MiBMxjEY+gUTCPdOUVz0xB8j viJweaYreGsxVaJx6wx4l2p7F5gdXnp/eUQXaPKU1g8N4n08MafjbUCMC1RC1HyegGP0 2ZbCybYj1sqpKeeYRWrEW0oHC7h9eA3XIl7E4ItdAULGDJHo3WMFMnjib1EirKU5e/aI fsgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704988373; x=1705593173; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=UOPot442UicpIvzFy/3DUpLZfqiliuk2E7eDZ6zcPbM=; b=d8bf2LfB6SxH2dHHmqhALkY3Pi3+QpzfeRiV7vXbhWUP70Qip/Gy3oPEp9Px1qlSt2 NvTto97EPhVOoSaO7Dkt//NMpPLzEFYnu8TnD8ux3zvj/Qe3knOPiibFSI6s8ih3+gJ1 Aa3YsSX50gv+ODk2dCXo/ntpFhNFvZtdTqdDYMXChSOCl9t2gQtPEsAMpoCA7xSLQWyr 6Ss90pWTYb7XNvEvoqKeFcv8o7QxS4ZHUHYz07mpbetJFC4HqiNoUH6F87TZQz+QFwLg RG8Kahkg3OHR90MZ1bxShfMNWLiB0H0QxBgXx7+3l1ECh12A8Gs0GrgW4dwHeydpYBOR 0WAQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YxCjfr9V+D9PrU6ewJ9JDoNDyi7F5IWFUqzx5WNQgLM0J8z1u5s W7jl5z9UNUtaPrAhcJER2iA= X-Google-Smtp-Source: AGHT+IH8917Znc+e8oEplTqHecDC6y2i78n5PP5fyFqRuorPzLysrl208g8kyoEW0pTGwBpRsPkUpg== X-Received: by 2002:a05:6512:31cb:b0:50e:72fc:aff5 with SMTP id j11-20020a05651231cb00b0050e72fcaff5mr1072557lfe.36.1704988372345; Thu, 11 Jan 2024 07:52:52 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:2803:b0:50e:75a3:580b with SMTP id cf3-20020a056512280300b0050e75a3580bls288486lfb.1.-pod-prod-04-eu; Thu, 11 Jan 2024 07:52:50 -0800 (PST) X-Received: by 2002:a2e:8283:0:b0:2cd:633c:6351 with SMTP id y3-20020a2e8283000000b002cd633c6351mr476668ljg.10.1704988370554; Thu, 11 Jan 2024 07:52:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704988370; cv=none; d=google.com; s=arc-20160816; b=bost8rNc2xmd67mBs+EDD5SwKleAMZJL82VNUlUWReS5I7y+Zqjdt9XZBsYpxJfqFx kYD9p4LH2wcoKpa3YngvSG9sGvVBSBfrkAR1VrTv607KFzPZyEVjzu4VEQAwMOfe5xwB Na2WeGIEMTFquSOko5kOSAZvtQUWoFh0buXUmPSb73shium4XVZdxBNZCYF+m5P8nWwn +HSyHGg8hb1ccgYE4fziS5lJfOcyH2hadl9F8/J+hfxkxgU9UAK8m1CPCYpOo3YIK05h wBTgxrMiXqA1bQ0Mv6GUiX400GnQexRSCNIWFDgFanoPZme1NS2iVFdyNFkM687/oJKn l2Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=pajsGGZ3ht6uaxCRGO5kRSxonziC98pCgidPVxIG1Gw=; fh=BeBIh3RcaIvLvchNldgBWZyKgRnQIUIPJvMX5Pb5emE=; b=UK3MJtZ/MMe+yR3scRRyie/blKsPAWurCN5TyetIPd8S29V+fmU/t1xmXATtf6CB1T k2z2OeUvth+jhYw+dMDSD8kRN3BTSFDZ8wrkyHeFSvrZaSZgWQhKVWaZIZSlMx5QQImw bYdvkuFFeIi/LqPbaaOU0hRzHVylZ2fIHrdxv1ZxPj8mDgidSH0JGN7XJYQzNaMS9XSW 0llAlIrIvviYnRuYAmSrNc/V+awUNEOTAW2bqFfWGIJL1sy7awWhiJ64+Tbi1Xc59/fk J1DCNl0GkF+HKaqZ5ljwOEXi76p3XPIUG8utye/H15cHSy6/psCESLP6nWm/84tx2D0c p0RQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id q26-20020a2e915a000000b002ccdcc1fd1csi49573ljg.6.2024.01.11.07.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 07:52:50 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M2wCg-1rRF9R2Zu0-003MuK; Thu, 11 Jan 2024 16:52:49 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Michael Glembotzki Subject: [swupdate] [PATCH V2 2/2] BUG: post-update command is no longer called from mongoose interface Date: Thu, 11 Jan 2024 16:52:46 +0100 Message-Id: <20240111155246.668425-3-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240111155246.668425-1-stefano.babic@swupdate.org> References: <20240111155246.668425-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:RDGLPnApWavu3MEhRe30OB8M2CWQ82Go5GFnCLUyUOZgabn2cAC nxdZmIjHjLPQyEkfWGvrn7b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WwBB1+9dLS8k1mZHj9TxT9zXs QY59wSFLVTcAkOQ== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org 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: , post-update is not called anymore. Reason are commit 8fccd13 and d116870 because they force the source of an update independently from the real source. The source for an update is set when a install request is sent and cached into core. The progress interface must retrieve the source and be stateless for it. Signed-off-by: Stefano Babic Reported-by: Michael Glembotzki Signed-off-by: Stefano Babic Reported-by: Michael Glembotzki --- core/notifier.c | 5 ++--- core/progress_thread.c | 15 ++++++++------- core/stream_interface.c | 9 +++++++-- corelib/channel_curl.c | 2 +- include/progress.h | 2 +- include/util.h | 3 ++- mongoose/mongoose_interface.c | 4 ++-- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/core/notifier.c b/core/notifier.c index 15220605..aec7a139 100644 --- a/core/notifier.c +++ b/core/notifier.c @@ -352,7 +352,6 @@ static void progress_notifier (RECOVERY_STATUS status, int event, int level, con { int dwl_percent = 0; unsigned long long dwl_bytes = 0; - sourcetype source = SOURCE_UNKNOWN; (void)level; /* Check just in case a process want to send an info outside */ @@ -360,8 +359,8 @@ static void progress_notifier (RECOVERY_STATUS status, int event, int level, con return; if (event == RECOVERY_DWL && - (sscanf(msg, "%d-%llu-%d", &dwl_percent, &dwl_bytes, (int *)&source) == 3)) { - swupdate_download_update(dwl_percent, dwl_bytes, source); + (sscanf(msg, "%d-%llu", &dwl_percent, &dwl_bytes) == 2)) { + swupdate_download_update(dwl_percent, dwl_bytes); return; } diff --git a/core/progress_thread.c b/core/progress_thread.c index 161d2f61..269c85d3 100644 --- a/core/progress_thread.c +++ b/core/progress_thread.c @@ -85,6 +85,7 @@ static void send_progress_msg(void) buf = &pprog->msg; count = sizeof(pprog->msg); errno = 0; + pprog->msg.source = get_install_source(); while (count > 0) { int attempt = 0; do { @@ -107,7 +108,7 @@ static void send_progress_msg(void) } } -static void _swupdate_download_update(unsigned int perc, unsigned long long totalbytes, sourcetype source) +static void _swupdate_download_update(unsigned int perc, unsigned long long totalbytes) { /* * TODO: totalbytes should be forwarded correctly @@ -117,7 +118,6 @@ static void _swupdate_download_update(unsigned int perc, unsigned long long tota pthread_mutex_lock(&pprog->lock); if (perc != pprog->msg.dwl_percent) { pprog->msg.status = DOWNLOAD; - pprog->msg.source = source; pprog->msg.dwl_percent = perc; pprog->msg.dwl_bytes = totalbytes; send_progress_msg(); @@ -133,9 +133,10 @@ void swupdate_progress_init(unsigned int nsteps) { pprog->msg.nsteps = nsteps; pprog->msg.cur_step = 0; pprog->msg.status = START; - pprog->msg.cur_percent = 0; - pprog->msg.infolen = get_install_info(&pprog->msg.source, pprog->msg.info, + pprog->msg.cur_percent = 0; + pprog->msg.infolen = get_install_info(pprog->msg.info, sizeof(pprog->msg.info)); + pprog->msg.source = get_install_source(); send_progress_msg(); /* Info is just an event, reset it after sending */ pprog->msg.infolen = 0; @@ -161,7 +162,7 @@ void swupdate_progress_update(unsigned int perc) pthread_mutex_unlock(&pprog->lock); } -void swupdate_download_update(unsigned int perc, unsigned long long totalbytes, sourcetype source) +void swupdate_download_update(unsigned int perc, unsigned long long totalbytes) { char info[PRINFOSIZE]; /* info */ @@ -175,13 +176,13 @@ void swupdate_download_update(unsigned int perc, unsigned long long totalbytes, * and decode them in the notifier, in this case * the progress_notifier */ - snprintf(info, sizeof(info) - 1, "%d-%llu-%d", perc, totalbytes, source); + snprintf(info, sizeof(info) - 1, "%d-%llu", perc, totalbytes); notify(PROGRESS, RECOVERY_DWL, TRACELEVEL, info); return; } /* Called by main process, emit a progress message */ - _swupdate_download_update(perc, totalbytes, source); + _swupdate_download_update(perc, totalbytes); } void swupdate_progress_inc_step(const char *image, const char *handler_name) diff --git a/core/stream_interface.c b/core/stream_interface.c index 0b783291..b9bce6d7 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -710,6 +710,7 @@ void *network_initializer(void *data) pthread_mutex_lock(&stream_mutex); inst.status = IDLE; + inst.req.source = SOURCE_UNKNOWN; pthread_mutex_unlock(&stream_mutex); TRACE("Main thread sleep again !"); notify(IDLE, RECOVERY_NO_ERROR, INFOLEVEL, "Waiting for requests..."); @@ -779,15 +780,19 @@ void get_install_running_mode(char *buf, size_t len) * The data is not locked because it is retrieve * at different times */ -int get_install_info(sourcetype *source, char *buf, size_t len) +int get_install_info(char *buf, size_t len) { len = min(len - 1, strlen(inst.req.info)); strncpy(buf, inst.req.info, len); - *source = inst.req.source; return len; } +sourcetype get_install_source(void) +{ + return inst.req.source; +} + void set_version_range(const char *minversion, const char *maxversion, const char *current) { diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 33dbbd7f..35f7f37f 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -463,7 +463,7 @@ static int channel_callback_xferinfo(void *p, curl_off_t dltotal, curl_off_t dln DEBUG("Downloaded %d%% (%zu of %zu kB).", percent, (size_t)dlnow / 1024, (size_t)dltotal / 1024); - swupdate_download_update(percent, dltotal, data->source); + swupdate_download_update(percent, dltotal); return 0; } diff --git a/include/progress.h b/include/progress.h index de680f47..64fa23d7 100644 --- a/include/progress.h +++ b/include/progress.h @@ -24,6 +24,6 @@ void swupdate_progress_end(RECOVERY_STATUS status); void swupdate_progress_done(const char *info); void swupdate_progress_info(RECOVERY_STATUS status, int cause, const char *msg); -void swupdate_download_update(unsigned int perc, unsigned long long totalbytes, sourcetype source); +void swupdate_download_update(unsigned int perc, unsigned long long totalbytes); void *progress_bar_thread (void *data); diff --git a/include/util.h b/include/util.h index 062840fc..490014e7 100644 --- a/include/util.h +++ b/include/util.h @@ -245,7 +245,8 @@ unsigned char *get_aes_ivt(void); int set_aes_key(const char *key, const char *ivt); /* Getting global information */ -int get_install_info(sourcetype *source, char *buf, size_t len); +int get_install_info(char *buf, size_t len); +sourcetype get_install_source(void); void get_install_swset(char *buf, size_t len); void get_install_running_mode(char *buf, size_t len); char *get_root_device(void); diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 4b61acb1..39dca711 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -584,7 +584,7 @@ static void upload_handler(struct mg_connection *nc, int ev, void *ev_data, break; } - swupdate_download_update(0, mp->len, SOURCE_WEBSERVER); + swupdate_download_update(0, mp->len); if (swupdate_file_setnonblock(fus->fd, true)) { WARN("IPC cannot be set in non-blocking, fallback to block mode"); @@ -637,7 +637,7 @@ static void upload_handler(struct mg_connection *nc, int ev, void *ev_data, percent = (uint8_t)(100.0 * ((double)fus->len / (double)mp->len)); if (percent != fus->percent) { fus->percent = percent; - swupdate_download_update(fus->percent, mp->len, SOURCE_WEBSERVER); + swupdate_download_update(fus->percent, mp->len); } fus->last_io_time = mg_millis();