From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7853 invoked from network); 18 Sep 2022 21:11:17 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 18 Sep 2022 21:11:17 -0000 Received: (qmail 18261 invoked by uid 89); 18 Sep 2022 21:11:42 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 18254 invoked from network); 18 Sep 2022 21:11:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antonovs.family; s=20200215; t=1663535467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wv5IrJiZtRQ1xkrF1nt44VoxEyZ9OSSXbAlMhk4PBEg=; b=IAxMBCblZJAjuvIMCflOsh1xi+75xGZizjDvAsabX2CjbuhPnlKP9BJpmfycJm/mhXWobd FxlfZ4K3sKC/mxth7FWPdT88Q7iH4lrPA/1WxrMDDXCMJtwwKqxmexvjBKxlSlC5OLDpJv C9r6L5jvZJKAshpp44wpXCsUzokpz8M= Date: Sun, 18 Sep 2022 14:11:16 -0700 From: Ihor Antonov To: Laurent Bercot Cc: supervision@list.skarnet.org Subject: Re: ftrig pipe naming convention Message-ID: <20220918211116.2iqsjmqdcqdw3t6h@localhost> References: <20220918154159.che33klmotj6nps6@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On 2022-09-18 20:38, Laurent Bercot wrote: > > > I wonder what is the reason behind the naming convention? What is the > > downside of simply writing to any present fifo file ? > > It could work like you're suggesting. But : > > - checking the type of a file is an additional fstat() system call > - there may be reasons in the future to store other files in the > fifodir that do not receive the event > - it is nice to detect stale fifos, if any, and delete them as soon > as you can (#L39), and you don't want to delete unrelated files > - but most importantly: creating a fifo in a fifodir that allows you to > receive events without a race condition, which is the whole point of the > ftrig library, is slightly more complex to do safely than just "mkfifo > event/foobar", and I don't want people to think that this is the API. > No, the API is ftrigr_subscribe(), and everything under it is > implementation details. Restricting the naming is a way of ensuring > (as much as possible) that the fifos were indeed created by the > appropriate programs. Could you please elaborate on the possible race condition? This is simply for curiosity and educational purposes. It feels like a lot of thought was put into s6 codebase, and a lot of ideas are not immediatedly obvious for people not intimately familiar with OS interface. > > Don't create fifos willy-nilly in a fifodir, and since you found the > naming convention, don't use it to work around the check to create your > fifos outside of ftrigr_subscribe(). If you do, it will work, until the > time when it doesn't, and it will be a complete PITA to debug. This does make the most sense. We could say that pipes are also implementation detail. There could be a socket, or, say, a regular file (aka event log). So hiding this behind an interface is very reasonable. > -- > Laurent >