Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85DBEC07E96 for ; Tue, 6 Jul 2021 16:37:05 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E817E61C3C for ; Tue, 6 Jul 2021 16:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E817E61C3C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 66A3882D97; Tue, 6 Jul 2021 18:37:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CuwycKpU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2339C82D99; Tue, 6 Jul 2021 18:37:01 +0200 (CEST) Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BD80282C4C for ; Tue, 6 Jul 2021 18:36:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x236.google.com with SMTP id s24so10172938oiw.2 for ; Tue, 06 Jul 2021 09:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eIjqF+2JfZhOeqnV9M3vGROd62jSeKwLLZHMfpgzoU0=; b=CuwycKpUNUDvYB7RrFuw6zyFf61UTzXfByllnnRauBq1vhO34Opnn58172DJhycbWQ VF3y8wWaoQuVxAa9BJpx9HTjRzI/HLPtrom/TNuLMGuJWoEdoSmdGSfhAdMmO1Sd5t9N 0SThdCOCfahQOAkbtvFgSJBnp/sBpTKZg5sO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eIjqF+2JfZhOeqnV9M3vGROd62jSeKwLLZHMfpgzoU0=; b=dFrWbxXmjSMVrx+xKrYcByLY6iT3ADzb5ENNcZp2L0JTvPRXx3x3rxh4G3grNc/fup 2ppSrH1CHSOZJ8km4/frd1M4VJw1h81Z5UU5qvQOF1EQSyXao+bUlJbZEIGlRK9Ce6BK geUE/+du2nVGGz1/1SFjdCRh/tqM72jYufQROSIKSlQH+7hXFvd4AsWaD2xKlbncvRvo DkV4EeoT/UCvDE8jbGnq0Fv3mUh83CDnuopf9mUCrcEdKa7XipnnpeRaB/hroJT04It7 9N0cONNlSER2KavK11SvGFkXhafZTYvj7wH1GCEsiEELP4E37MxKo0o7AawVtV2Nb1+n +AFw== X-Gm-Message-State: AOAM531YxDl8F9TXp+JGzG56Xlxc4884SnIZk6ABwj8fJr8MYbxGNXXF 82wgev3/HBG4LiIYHExGT926gvRz7xbcnePg X-Google-Smtp-Source: ABdhPJxHxlpIEw2SLlx4IFT9dDfmu2cxDIv8e/U98k12+DH5aY7CGbOiZm04xPQgPA6cJ0pypeoxsw== X-Received: by 2002:aca:d842:: with SMTP id p63mr1174024oig.114.1625589415894; Tue, 06 Jul 2021 09:36:55 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id e74sm3336357ote.14.2021.07.06.09.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 09:36:55 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH 1/6] binman: Put compressed data into separate files Date: Tue, 6 Jul 2021 10:36:36 -0600 Message-Id: <20210706163641.2280401-2-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210706163641.2280401-1-sjg@chromium.org> References: <20210706163641.2280401-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean At present compression uses the same temporary file for all invocations. With multithreading this causes the data to become corrupted. Use a different filename each time. Signed-off-by: Simon Glass --- tools/patman/tools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/patman/tools.py b/tools/patman/tools.py index ec95a543bd9..877e37cd8da 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -466,6 +466,9 @@ def Compress(indata, algo, with_header=True): This requires 'lz4' and 'lzma_alone' tools. It also requires an output directory to be previously set up, by calling PrepareOutputDir(). + Care is taken to use unique temporary files so that this function can be + called from multiple threads. + Args: indata: Input data to compress algo: Algorithm to use ('none', 'gzip', 'lz4' or 'lzma') @@ -475,14 +478,16 @@ def Compress(indata, algo, with_header=True): """ if algo == 'none': return indata - fname = GetOutputFilename('%s.comp.tmp' % algo) + fname = tempfile.NamedTemporaryFile(prefix='%s.comp.tmp' % algo, + dir=outdir).name WriteFile(fname, indata) if algo == 'lz4': data = Run('lz4', '--no-frame-crc', '-B4', '-5', '-c', fname, binary=True) # cbfstool uses a very old version of lzma elif algo == 'lzma': - outfname = GetOutputFilename('%s.comp.otmp' % algo) + outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo, + dir=outdir).name Run('lzma_alone', 'e', fname, outfname, '-lc1', '-lp0', '-pb0', '-d8') data = ReadFile(outfname) elif algo == 'gzip': -- 2.32.0.93.g670b81a890-goog