[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#1009712: sv: fails to control the service on Hurd



Hello,

João Pedro Malhado, le lun. 23 déc. 2024 14:35:27 +0000, a ecrit:
> So I made a test program fifo_mkrd_test.c that creates a fifo and attaches to it
> just like runsv does, and fifo_test.c which opens it and closes it twice with a
> sleep in between.

Thanks for the test case, it's indeed properly showing the issue.

>From reading hurd/trans/fifo.c's close_hook, it looks like it was
deliberate to make a last-writer closure make the whole pipe disappear.

    /* See if PIPE should cease to be the user-visible face of this fifo.  */
    detach =
      ((flags & O_READ) && pipe->readers == 1)
       || ((flags & O_WRITE) && pipe->writers == 1);

But the comment of the commit (a184f3a4f1a4ffd3191ad34579af9bf4d39abb20)
is different:

    (close_hook):
      Also disconnect ACTIVE_FIFO if the laster writer is going away and there
        were no readers.

but the code above does not actually check against there being no
readers any more.

There being no reader any more would have been caught by the original
code already:

       /* We're the last reader; when we're gone there is no more joy.  */
       detach = ((flags & O_READ) && pipe->readers == 1);

So probably that line could be restored as it was and just let the rest
as it is currently: in open_hook we properly make an incoming writer
either wait for a reader or immediately return ENXIO if here is none and
O_NDELAY was given.

Could you try to do the change and check that it fixes your issue? I
guess this poses problem to other kinds of control sockets, so it'll be
useful to fix.

Samuel


Reply to: