From patchwork Wed Apr 20 18:06:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564013 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4426669map; Wed, 20 Apr 2022 11:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpOENPkZWZj8EH2stYxWdIG49zTnps15BV9NbC/8rajX4UaTdaam8LNs0k3ihXDXWutqkp X-Received: by 2002:a05:6902:1c5:b0:644:d1dc:c325 with SMTP id u5-20020a05690201c500b00644d1dcc325mr19019122ybh.385.1650480480491; Wed, 20 Apr 2022 11:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480480; cv=none; d=google.com; s=arc-20160816; b=mLeDR7JgOUvB/jAks6v3Wx5Wkzl47FWMxwIkkxluLNsGEisdaSJRM9ygELlelemgqj mI74SCQUrEMLHMQPHbUyGy35n5+excKQ5qsyKePOlxmeJOzmkEXhk5Ynv1GTqifxqKoA uspau3qLSPz6zMmNz/Rs7PMhic+1pFzKBNmfMQPGhggUXYs1lGes5sdmm+nOACCYQZqF L33WiAnken0uwoH/6nORYdoSv7n5JVUMMaTfK30QLfXmiqbVaMKKzucRRbykRJ2qv2xD NwKhCMFRobCWEVZeEmhJRBZgHl6WECsRcN2aiWm4nl390NH0+DGU88Q9PKtoQ2vBMtol F1CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=u5EVNZ1bFVlHGXvLMPCxon1Zpy1jILDXUd9W4/cl/+yvzd13/86Pe6s5oEHOujVntf hgTCeTmbj/spJHjVdn47Ibh0+YxEN+oCoGMyqRKtD3wawmqqf8IIuE+NGRM9T7Saf1bD b7dPzViCSaNQFI0DccHlUOpwcwfBP3Vz6rMxqNLNOVToNIef/E2vxJT4X56W5vdfHD8/ Bema09Wdh5SIFqmCKnxvjjazF/+M9Vz7MtoRwS5nYTbOGkF+pfDTEqEnvcK9B/FZ9/to JEBOmhNNYdNo2F3lmbcCE3BO4Mo07TR7fRVCt5u26zke/j6ZlCZbz7sRZOF5iIOZYdFK NhFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jGCsMRja; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g126-20020a255284000000b00641cbcd6229si736900ybb.69.2022.04.20.11.48.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jGCsMRja; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFMu-0007Tt-0z for patch@linaro.org; Wed, 20 Apr 2022 14:48:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjD-0006Zu-K6 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:00 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:42737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjC-0001Nn-1l for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:59 -0400 Received: by mail-pl1-x62a.google.com with SMTP id s17so2504089plg.9 for ; Wed, 20 Apr 2022 11:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=jGCsMRja5Gwp//whq4PO3YeQQLG5uByk77rEj5xA90IexEj9/4//4lh3/yUVBR2j/E +tYCSb2wmgV4kjWy5rL6uvqHXiTfeMSKktc8ajmuULJW0BCbsvgZufNC7ZeV0kFoHxc9 cv9JYMef4Iup6kd1Bc2m7xz2g7IZ9gvyvp7e+62YQM9juWRTFUT+ilvplUdRhlzCPFOw D/2PEe+P7ArSsgoTCwVj0zAnuP3H3I5BbXiYgvX6dqL3SLAR/UUNAC7JnXumNq5j+TiR hI9Gbcrptw4asYFoumpjd3TWDdjR59R5vIHuid3D7trc6T5Ana617WRHPLdeNDg1rUMf UF6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=JltSBxCfwSbibpiGTaFKuwz5AdB70+Rgx45bdlYo7xA6FRA/p2h0s4jCJZN0jwJvyZ vONfyxbUNTFtS627kDqSdjf+P2D9Yigm/n9pqmLtxsy/j++WaKS5tOhhPAEBBF1ebmQS o01Getxn06G4PS9wAPol0W7BA7ThjyfEXHQKDdBY+Xf4QnhlFez3U7Jje7GVWuhrU3rg i/PdDHLWHElgo7C/npRRIktJl1xdrAH964Tl0iO9FVpVE72HisLqAmeAKUxy8FMqwPXc HpjO+Cgy9In3kCkFFyoSGixPNBbHT9Q1nxXsYDLtQu2jXY0ng5PiZgk1uX/1tm6MnTxe umYw== X-Gm-Message-State: AOAM531BHPJPetioig85BRhjgUKfOZ86g7CsgabxxeShOTI2T9WgRY7D mng+J7D6m1qYqs5pMzxZ2njduR4FeDzqWA== X-Received: by 2002:a17:90b:3b4b:b0:1d2:e3fe:e1a1 with SMTP id ot11-20020a17090b3b4b00b001d2e3fee1a1mr5867777pjb.239.1650478016808; Wed, 20 Apr 2022 11:06:56 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/39] util/log: Combine two logfile closes Date: Wed, 20 Apr 2022 11:06:15 -0700 Message-Id: <20220420180618.1183855-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Merge the close from the changed_name block with the close from the !need_to_open_file block. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-37-richard.henderson@linaro.org> --- util/log.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index 631856e231..21da961d8d 100644 --- a/util/log.c +++ b/util/log.c @@ -157,12 +157,6 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, g_free(global_filename); global_filename = newname; filename = newname; - - if (logfile) { - qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - logfile = NULL; - } } else { filename = global_filename; } @@ -182,11 +176,12 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, daemonized = is_daemonized(); need_to_open_file = log_flags && (!daemonized || filename); - if (logfile && !need_to_open_file) { + if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - return true; + logfile = NULL; } + if (!logfile && need_to_open_file) { FILE *fd;