On Thu, Jul 12, 2018 at 02:38:48PM +0200, Martin Pieuchot wrote: > @@ -83,12 +91,6 @@ soo_ioctl(struct file *fp, u_long cmd, c > switch (cmd) { > > case FIONBIO: > - s = solock(so); > - if (*(int *)data) > - so->so_state |= SS_NBIO; > - else > - so->so_state &= ~SS_NBIO; > - sounlock(so, s); > break;
man 2 ioctl documents FIONBIO. Should we set or clear FNONBLOCK instead? > @@ -1128,8 +1126,7 @@ sosplice(struct socket *so, int fd, off_ > /* If no fd is given, unsplice by removing existing link. */ > if (fd < 0) { > /* Lock receive 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) { > return (error); > } > if (so->so_sp->ssp_socket) > @@ -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(). > @@ -223,12 +223,11 @@ fifo_read(void *v) > if (uio->uio_resid == 0) > return (0); > if (ap->a_ioflag & IO_NDELAY) > - rso->so_state |= SS_NBIO; > + flags = MSG_DONTWAIT; I think a |= would be nicer here. > @@ -245,20 +244,17 @@ fifo_write(void *v) > { > struct vop_write_args *ap = v; > struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock; > - int error; > + int error, flags = 0; > > #ifdef DIAGNOSTIC > if (ap->a_uio->uio_rw != UIO_WRITE) > panic("fifo_write mode"); > #endif > - /* XXXSMP changing state w/o lock isn't safe. */ > if (ap->a_ioflag & IO_NDELAY) > - wso->so_state |= SS_NBIO; > + flags = MSG_DONTWAIT; And |= also here. > @@ -384,8 +380,8 @@ fifo_close(void *v) > } > } > if (fip->fi_readers == 0 && fip->fi_writers == 0) { > - error1 = soclose(fip->fi_readsock); > - error2 = soclose(fip->fi_writesock); > + error1 = soclose(fip->fi_readsock, MSG_DONTWAIT); > + error2 = soclose(fip->fi_writesock, MSG_DONTWAIT); > free(fip, M_VNODE, sizeof *fip); > vp->v_fifoinfo = NULL; > } You are adding MSG_DONTWAIT to a bunch of closes. Are you sure that you do not change behavior here? Does a blocking fifo close with SO_LINGER wait for the other end? > @@ -433,7 +433,7 @@ nfs_disconnect(struct nfsmount *nmp) > so = nmp->nm_so; > nmp->nm_so = NULL; > soshutdown(so, SHUT_RDWR); > - soclose(so); > + soclose(so, MSG_DONTWAIT); > } > } NFS never sets SS_NBIO, so I think we should not use MSG_DONTWAIT. bluhm