supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: "Laurent Bercot" <ska-supervision@skarnet.org>
To: supervision@list.skarnet.org
Subject: Re: ftrig pipe naming convention
Date: Sun, 18 Sep 2022 20:38:27 +0000	[thread overview]
Message-ID: <em965f3604-6dab-474c-b860-12144209ed0b@e87ce782.com> (raw)
In-Reply-To: <20220918154159.che33klmotj6nps6@localhost>


>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.

  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.

--
  Laurent


  reply	other threads:[~2022-09-18 20:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 15:41 Ihor Antonov
2022-09-18 20:38 ` Laurent Bercot [this message]
2022-09-18 21:11   ` Ihor Antonov
2022-10-04 11:54     ` Laurent Bercot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=em965f3604-6dab-474c-b860-12144209ed0b@e87ce782.com \
    --to=ska-supervision@skarnet.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).