On Thu, Jul 12, 2018 at 06:18:06PM +0200, Martin Pieuchot wrote:
> > > @@ -1157,8 +1154,7 @@ sosplice(struct socket *so, int fd, off_
> > >   }
> > >  
> > >   /* Lock both receive and send buffer. */
> > > - if ((error = sblock(so, &so->so_rcv,
> > > -     (so->so_state & SS_NBIO) ? M_NOWAIT : M_WAITOK)) != 0) {
> > > + if ((error = sblock(so, &so->so_rcv, M_WAITOK)) != 0) {
> > >           goto frele;
> > >   }
> > >   if ((error = sblock(so, &sosp->so_snd, M_WAITOK)) != 0) {
> > 
> > I have copied the logic from soreceive.  So I think sosplice should
> > also use FNONBLOCK.  That would mean to pass the f_flag to sosetopt().
> 
> I'm not fan of this plumbing.  So unless you can explain why M_NOWAIT is
> needed here I don't see why we should have it.
> 
> Do you have any code checking for EWOULDBLOCK after calling setsockopt()
> with SO_SPLICE?  Plus since we have a rwlock as socket lock, most of
> this logic isn't relevant.

My idea was to give it the same semantics as soreceive() and sosend().
It seems that sblock() could only block if another thread has locked
the socket buffer and is waiting for memory or copyin/copyout sleeps.
These should be short term sleeps and it is questionable to return
EWOULDBLOCK anyway.

So let's do it the easy way for socket splicing and wait for sblock().
I have not found code that checks for EWOULDBLOCK.  Relays do not
access the same sockets in multiple threads anyway.

OK bluhm@

Reply via email to