NetBSD-Bugs archive

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

Re: kern/57369: unexpected poll timeout on pipe



The following reply was made to PR kern/57369; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57369: unexpected poll timeout on pipe
Date: Thu, 20 Apr 2023 06:48:24 -0000 (UTC)

 mlelstv%serpens.de@localhost (Michael van Elst) writes:
 
 >The following reply was made to PR kern/57369; it has been noted by GNATS.
 
 >From: mlelstv%serpens.de@localhost (Michael van Elst)
 >To: gnats-bugs%netbsd.org@localhost
 >Cc: 
 >Subject: Re: kern/57369: unexpected poll timeout on pipe
 >Date: Thu, 20 Apr 2023 06:22:36 -0000 (UTC)
 
 > yamt9999%gmail.com@localhost writes:
 > 
 > >please see the following test code.
 > >(it's available on github as well: https://github.com/yamt/garbage/blob/master/c/poll/test.c)
 > >it succeeds on macOS and ubuntu.
 > >but on netbsd, poll times out. (returns 0)
 > >its 9.3 GENERIC kernel + older userland if it matters.
 > 
 > 
 > This can be changed with:
 > 
 > Index: sys/kern/sys_pipe.c
 > ===================================================================
 > RCS file: /cvsroot/src/sys/kern/sys_pipe.c,v
 > retrieving revision 1.158
 > diff -p -u -r1.158 sys_pipe.c
 > --- sys/kern/sys_pipe.c 11 Oct 2021 01:07:36 -0000      1.158
 > +++ sys/kern/sys_pipe.c 20 Apr 2023 06:20:45 -0000
 > @@ -846,7 +846,7 @@ pipe_poll(file_t *fp, int events)
 >                 revents |= POLLHUP;
 >  
 >         if (revents == 0) {
 > -               if (events & (POLLIN | POLLRDNORM))
 > +               if (events & (POLLIN | POLLHUP | POLLRDNORM))
 >                         selrecord(curlwp, &rpipe->pipe_sel);
 >  
 >                 if (events & (POLLOUT | POLLWRNORM))
 > 
 > 
 > But I don't see that this has ever worked. It also doesn't help (alone)
 > for the opposite direction.
 
 
 The write case is missed, because the EOF condition is set after
 notifying the peer.
 
 @@ -973,8 +973,8 @@ pipeclose(struct pipe *pipe)
          * Disconnect from peer.
          */
         if ((ppipe = pipe->pipe_peer) != NULL) {
 -               pipeselwakeup(ppipe, ppipe, POLL_HUP);
                 ppipe->pipe_state |= PIPE_EOF;
 +               pipeselwakeup(ppipe, ppipe, POLL_HUP);
                 cv_broadcast(&ppipe->pipe_rcv);
                 ppipe->pipe_peer = NULL;
         }
 
 A few lines earlier (waking openers of the closing
 side) seems to be the wrong order too.
 
 
 


Home | Main Index | Thread Index | Old Index