From patchwork Thu Dec 31 11:22:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1421530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13c; helo=mail-lf1-x13c.google.com; envelope-from=swupdate+bncbcxploxj6ikrbe7jw37qkgqesmvlusa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=mRGPE8jD; dkim-atps=neutral Received: from mail-lf1-x13c.google.com (mail-lf1-x13c.google.com [IPv6:2a00:1450:4864:20::13c]) (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 ozlabs.org (Postfix) with ESMTPS id 4D65P534Hsz9sRf for ; Thu, 31 Dec 2020 22:23:02 +1100 (AEDT) Received: by mail-lf1-x13c.google.com with SMTP id i21sf11564987lfe.14 for ; Thu, 31 Dec 2020 03:23:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1609413779; cv=pass; d=google.com; s=arc-20160816; b=dd1+7DNnv6q53/nZboY+9q7bhg+/WEAbc9JiE74l48/92i7RrMoeQdsNOda/wKSmYm vemx3qDfYFiZkPSssOUL0oh3ZR223WaL6y9aJLXencQCp3hEGDPCmUfgAKLhJCMpdEQz j9Ux3v/6gLT1G905C+pS/DXaRHN54TGqgKt38UGoHvCbdPgMCNg+8fHfTioSriu9UykM 6OXJp39NcMXb+ADtxXq/bIGPaDYkwrqMvEgQ0Cq+Hc4IGpRHPpbpWgF9dl27RzDBJVg+ eeopd87bLRKDJ1rR8aup/JQXWjqiGH39Toh32sk43BYWtnJKac/cHQljFsPYkCBJrndT UDgQ== 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:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=i8Db1mbHpaxlBTTPNQsroocOnfrzr7u297kiTc/HCi8=; b=0Q+o7++FVw30DMD9eUVgYezomxQ1cc4Gj8jn47WG054yJl+ktFmQpMeCdEfY1I9HWw oNJRuA0BoBFBj8HpYvNKx832CHWHiPFLu3AQKd00X4eYe7FRN0N2VIgqateiFZWuImVp JejJZ/v6ucIr2/1gDB+t9ZeRZ7B5R32qoWv6jHYKHs2R0xF1iv/LPUraGb3OSM/HlKjs Px8I17FwJpqo8KIjf7K02QWz3XOwM/hidGQkr+6tzygfAl5C46/glNviaTBv3cTbWccR pgeu2UL1F+H29g0O/Oa2aYgRgZMHqoV+dh33EzfJVeX6fWz9IQKSWwp7s4HtwmdlMK3u /4nQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id: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=i8Db1mbHpaxlBTTPNQsroocOnfrzr7u297kiTc/HCi8=; b=mRGPE8jDYPdEJwexKULrVH4yWnYjc1pYyaUvgDdOHhtKMBa6xl/ihwsrw6KpyzKmm+ Ut1s2e2kKjidkB8K8IS8uJIT768lQaylbrbeTEtx7Ag4fsFIpYvn3DqPPZScgeDo6KUb KfYYtKy3UuqtYS67W/E2KeWGhEo8v37rS6rTY1+/mkRcr4HZWpy0akyja2Q0Siy8T/Qj 99g4qpYV/1pa4AlCFwK2VqcdI9gCVD4UcrSv48Ik8dArJgKP9Q3p06OzNQu3TlxNUw/2 i0oai29JXSJwMb/U6tZut5Wn26Ad10EuNN772US7LNRPQ67tp/DDiMUXxJl+G63D328b ChOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :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=i8Db1mbHpaxlBTTPNQsroocOnfrzr7u297kiTc/HCi8=; b=dQdAhWI8JUJ2eycx4xoYehuvZMeKM5CG6Tgpv8smUiNl4+HfYTNGp/n1AP0YZG9LHj dGVhbEmD8t8/meuwg1OXeg0TayvUQtb1jTlHqpThbuN0lg3ee2VKdOv59BfWfio+B0+I ZvtZ6viYSbzvqmy47wxkIx0iq/SAoviRDTIo43JreB3RYRiYhY8gS2xvtE4+wbgnlbI5 zZkyVhYp7oTjw5ZmxSStBEt6qMyleUmF4qyPhDDMiYgFHlErJwjNEgeHewap2pHCwICR 7SZgRtphuodGe1GnhZ5YC7ugrXRH7syA453n9kkogIUcK90s1yvt3ANMLmEkylRayT8G d0fQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5319/e0LCTnawKDL2DEqwn/FPlffiQ5vs7GR+40Ar7o5aShPEc7T 1CUIA26tkwG1jMOxlOm6BeY= X-Google-Smtp-Source: ABdhPJzDTQx6PYipk8XkLafYk64/lS14aCDEPyFjwHu9bNc5SDHiNPN2/Jno8dvGV9X/vA5Wa6Fvdg== X-Received: by 2002:ac2:5472:: with SMTP id e18mr24418053lfn.489.1609413779629; Thu, 31 Dec 2020 03:22:59 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:c886:: with SMTP id y128ls111678lff.0.gmail; Thu, 31 Dec 2020 03:22:58 -0800 (PST) X-Received: by 2002:a19:f249:: with SMTP id d9mr15990781lfk.158.1609413778405; Thu, 31 Dec 2020 03:22:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609413778; cv=none; d=google.com; s=arc-20160816; b=TylIwELJ0t7rnQRwouK9HgSrDmwf+3Kj19ggaUdxvmhqlCxSfbnqp5dECs0Wm+liNx cdK3oIc3oqLSmGhAwOhI8u5HKS04xifdkkH8wWYmvGlt6JO0fzyFhpqofQ1xC5M1ZA41 q2FYDSDrRv6cWWvVxtS9D5ENGmBxBilXsFORUgRio+DCuFpD/gW2btUwUrjkYJu7lNph PLzDP0W41kbHstrMZm0Jz1togTH3llVznCuy0E1ouiLoDaHLFtBpaE/hM7Hp5vPy3jPk +WquU8T2DM9UaQ1Rn2KHpFGy8PJ4lfJWPSPm96wzAo1GYQI5dnSy/pa8ce5FV6Jueq6Z WIPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=AmNkKsVetLkNHW5m0WltJj4T70rXrjtExeX3KCXPrsY=; b=zv7Ri3gE08GawBK1J+SFxyhjTMfDfNE6BiUMEit3XwXG3hg8A95nESIfPMQnC7ABOU b6TPlaMuYn1Wd8+5QU+NcJHJZKjgtUPizw3npyyDCvMjt/gmEkFbAxreohewxek1+2N6 4nX6Ot/HhtcaN+qqGd3CheXuI7Y8REFxYuHVelNmqSK9tGPEE2X0Imocm92TvgX3KwZ3 0dM7/DNVelRvF6ih5h4gkJ2f23+RgQHWSfErlF2AjdLOS4Z9a8CdLPMXYK5HgxpuHUIa Z+2L8U4Vy6Lo/zy8JA833Z/cOht6SR37TC1zurvqk6jmHTerlLNI0pueNaOW0DpDgOfj loxA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for 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.10]) by gmr-mx.google.com with ESMTPS id e18si1647416lfn.6.2020.12.31.03.22.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Dec 2020 03:22:58 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4D65Nx66Prz1rvBF; Thu, 31 Dec 2020 12:22:57 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4D65Nx5tdkz1qqkv; Thu, 31 Dec 2020 12:22:57 +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 CDF7Asxu1K7i; Thu, 31 Dec 2020 12:22:57 +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; Thu, 31 Dec 2020 12:22:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 9369D4540546; Thu, 31 Dec 2020 12:22:56 +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 BRXBmXhJZbMB; Thu, 31 Dec 2020 12:22:53 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id B80464540062; Thu, 31 Dec 2020 12:22:53 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Sync update from file with CV Date: Thu, 31 Dec 2020 12:22:52 +0100 Message-Id: <20201231112252.132665-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 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.10 is neither permitted nor denied by best guess record for 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: , Signed-off-by: Stefano Babic --- core/install_from_file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/install_from_file.c b/core/install_from_file.c index a595c30..987fa17 100644 --- a/core/install_from_file.c +++ b/core/install_from_file.c @@ -23,6 +23,7 @@ static pthread_mutex_t mymutex; static char buf[16 * 1024]; static int fd = STDIN_FILENO; static int end_status = EXIT_SUCCESS; +static pthread_cond_t cv_end = PTHREAD_COND_INITIALIZER; /* * this is the callback to get a new chunk of the * image. @@ -54,6 +55,8 @@ static int endupdate(RECOVERY_STATUS status) status == FAILURE ? "*failed* !" : "was successful !"); + pthread_mutex_lock(&mymutex); + pthread_cond_signal(&cv_end); pthread_mutex_unlock(&mymutex); return 0; @@ -71,10 +74,6 @@ int install_from_file(const char *filename, bool check) pthread_mutex_init(&mymutex, NULL); - /* synchronize with a mutex */ - pthread_mutex_lock(&mymutex); - - /* May be set non-zero by end() function on failure */ end_status = EXIT_SUCCESS; @@ -102,8 +101,7 @@ int install_from_file(const char *filename, bool check) /* Now block */ pthread_mutex_lock(&mymutex); - - /* End called, unlock and exit */ + pthread_cond_wait(&cv_end, &mymutex); pthread_mutex_unlock(&mymutex); if (filename)