From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C2113EC81F for ; Tue, 4 Aug 2026 08:03:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785830606; cv=none; b=XAPXXuga6ATPytyQ1F5HSu1NhlpF3IzVllZh7pWVQiw6hpgYf4QueyEIQ4zwPccUjdgjM2gu0XsaV1yrUbk9SZ5ZklMgPgTcI0MmBoFxnIxOyCT1rtLK3g2MiPOT9b1CB8kZHmTIjVEERAuJBi5bd1yjbTUOASHpFzwp/OsG3CE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785830606; c=relaxed/simple; bh=nyOXCO2OEYrSF6DvMpAzBpU0kVKCP4L3qnqa08eUBwM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EULsbv1ail8Bwkyemmc0b1LzT7QGfIuu0tDovzRI6s6s0uSa/E8Ktw0hfyw7LpDihDHLVBPgeQhGtUcUfJhTTFo4fYrFbTL+pIMrmZq2qojsD2XIeXD2+fJklZ7/o0aiAFqMc3dBxzHAPmbJelj1WZTGR2Jkp/ZNtK60N79FF6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=KTl+uY6/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=CfjAFTiK; arc=none smtp.client-ip=202.12.124.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="KTl+uY6/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="CfjAFTiK" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 738A27A0045; Tue, 4 Aug 2026 04:03:24 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Tue, 04 Aug 2026 04:03:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1785830604; x=1785917004; bh=9eD/0IjjSB cqOyJGyNgZ/+uc8WlB04kxPZS/DXvYKtw=; b=KTl+uY6/aFLyA92yL8f8JtVzIZ zvh9CXGQ2MP5bx9Tvr4aujNNPJgHEt+QlnNkCMt/Tw24qEL+2bzOp06yuXMIe6Tm MntGs2E/MLgpxxEWzps7y53MqiygL1c3XFfaMnUld2EwIuBfbU0MYIrjvKgCT2zj gcDX8+sCmwqF+3X4vDmp4F1HxX0XHmwbTUEOAw+B2NsIKi7o0rNKP3E+tZspVtX3 KviH5L2oM5ZXPDn/NLMP4ZTsFBV2nR1Y3Wh3PwPU+aNvCHLAvybs8EaP56Pmq0uJ MkpAsw5KKLiP3SJnYlj/nMIL8IrC65HHJVXch5wgwdE0x1pNZMhXkOspipIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1785830604; x=1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dWmbQ30n2aitmbZh/z4F4yuOxkXjTnaI47X7V42rCNs6g X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Aug 2026 04:03:23 -0400 (EDT) Received: by mail (OpenSMTPD) with ESMTPSA id d31cbc0b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 4 Aug 2026 08:03:22 +0000 (UTC) Date: Tue, 4 Aug 2026 10:03:19 +0200 From: Patrick Steinhardt To: Michael Montalbo via GitGitGadget Cc: git@vger.kernel.org, Michael Montalbo Subject: Re: [PATCH v2 3/3] t/README: document writing concurrency-safe helpers Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jul 10, 2026 at 05:30:57PM +0000, Michael Montalbo via GitGitGadget wrote: > diff --git a/t/README b/t/README > index 085921be4b..a9d425f392 100644 > --- a/t/README > +++ b/t/README > @@ -854,6 +854,38 @@ from the test harness library. At the end of the script, call > 'test_done'. > > > +Writing concurrency-safe helpers > +-------------------------------- Nit: this paragraph is quite specific to lib-httpd, so it would make sense to mention it in the header here. E.g. Writing concurrency-safe lib-httpd helpers > +Some test code runs concurrently: a test may background work with '&', > +and the helper scripts installed for the web server (in t/lib-httpd) are > +run once per request, so the same script can execute for several > +requests at once. Such code cannot assume it has exclusive access to a > +file. > + > +When exactly one of several concurrent processes needs to "win" a > +decision, a single atomic filesystem operation can make it, rather than > +a check followed by a separate action. A "test -f X" then "touch X" > +(or "rm X") races: two processes can both pass the check before either > +acts. Two atomic operations avoid this: > + > + - "mkdir dir", which fails if the directory already exists, so that > + exactly one caller wins, electing a first or only request (see > + t/lib-httpd/http-429.sh). > + > + - "mv src dst" (rename), which fails if the source is gone, so that > + exactly one caller consumes it, claiming a planted one-shot marker > + (see t/lib-httpd/apply-one-time-script.sh). A simple "rm" (without "-f") should work as well, right? > +A "$$" suffix on per-request scratch files keeps concurrent invocations > +from clobbering each other's fixed-name files. Nit: it might be a bit easier to read if we explicitly mention PIDs instead of assuming that every reader immediately knows that "$$" will expand to the PID. E.g.: Appending a PID to the per-request scratch filenames keeps... Thanks! Patrick