Re: recvmsg() "short receive" after FIONREAD

2021-09-12 Thread Andriy Gapon
On 11/09/2021 21:40, Mark Johnston wrote: On Sat, Sep 11, 2021 at 09:25:42PM +0300, Andriy Gapon wrote: So, this is what I've got: diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index e53b0367960b..11ee03703407 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -210,7

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Mark Johnston
On Sat, Sep 11, 2021 at 09:25:42PM +0300, Andriy Gapon wrote: > On 11/09/2021 17:28, Andriy Gapon wrote: > > On 11/09/2021 17:16, Andriy Gapon wrote: > >> On 11/09/2021 17:13, Mark Johnston wrote: > >>> I think the semantic change is ok.  Did you change FIONREAD to lock the > >>> sockbuf?  I think

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Andriy Gapon
On 11/09/2021 17:28, Andriy Gapon wrote: On 11/09/2021 17:16, Andriy Gapon wrote: On 11/09/2021 17:13, Mark Johnston wrote: I think the semantic change is ok.  Did you change FIONREAD to lock the sockbuf?  I think it would be necessary to avoid races with pulseaudio: sb_acc is modified before s

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Andriy Gapon
On 11/09/2021 17:16, Andriy Gapon wrote: On 11/09/2021 17:13, Mark Johnston wrote: I think the semantic change is ok.  Did you change FIONREAD to lock the sockbuf?  I think it would be necessary to avoid races with pulseaudio: sb_acc is modified before sb_ctl, so there could be windows where sba

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Andriy Gapon
On 11/09/2021 17:13, Mark Johnston wrote: I think the semantic change is ok. Did you change FIONREAD to lock the sockbuf? I think it would be necessary to avoid races with pulseaudio: sb_acc is modified before sb_ctl, so there could be windows where sbavail(sb) - sb->sb_ctl gives a larger. And

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Mark Johnston
On Sat, Sep 11, 2021 at 11:15:12AM +0300, Andriy Gapon wrote: > On 10/09/2021 22:40, Andriy Gapon wrote: > > On 10/09/2021 22:38, Andriy Gapon wrote: > >> On 10/09/2021 22:35, Mark Johnston wrote: > >>> Indeed, I suspect that this is the problem.  Note that for > >>> kevent(EVFILT_READ) we subtract

Re: recvmsg() "short receive" after FIONREAD

2021-09-11 Thread Andriy Gapon
On 10/09/2021 22:40, Andriy Gapon wrote: On 10/09/2021 22:38, Andriy Gapon wrote: On 10/09/2021 22:35, Mark Johnston wrote: Indeed, I suspect that this is the problem.  Note that for kevent(EVFILT_READ) we subtract the number of control message bytes from the returned value, see filt_soread(). 

Re: recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Andriy Gapon
On 10/09/2021 22:38, Andriy Gapon wrote: On 10/09/2021 22:35, Mark Johnston wrote: Indeed, I suspect that this is the problem.  Note that for kevent(EVFILT_READ) we subtract the number of control message bytes from the returned value, see filt_soread().  I wonder if FIONREAD should do the same t

Re: recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Andriy Gapon
On 10/09/2021 22:35, Mark Johnston wrote: On Fri, Sep 10, 2021 at 10:15:37PM +0300, Andriy Gapon wrote: On 10/09/2021 21:51, Andriy Gapon wrote: I observe a problem with the code that can be seen here: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L1

Re: recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Mark Johnston
On Fri, Sep 10, 2021 at 10:15:37PM +0300, Andriy Gapon wrote: > On 10/09/2021 21:51, Andriy Gapon wrote: > > > > > > I observe a problem with the code that can be seen here: > > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L142 > > > > > > > > The c

Re: recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Mark Johnston
On Fri, Sep 10, 2021 at 09:51:38PM +0300, Andriy Gapon wrote: > > > I observe a problem with the code that can be seen here: > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L142 > > The code uses ioctl(FIONREAD) to check the size of available data in a

Re: recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Andriy Gapon
On 10/09/2021 21:51, Andriy Gapon wrote: I observe a problem with the code that can be seen here: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L142 The code uses ioctl(FIONREAD) to check the size of available data in a socket. Does / should this w

recvmsg() "short receive" after FIONREAD

2021-09-10 Thread Andriy Gapon
I observe a problem with the code that can be seen here: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L142 The code uses ioctl(FIONREAD) to check the size of available data in a socket. Does / should this work? Then the code calls recvmsg() on the s