diff options
author | truckman <truckman@FreeBSD.org> | 2004-06-01 01:18:51 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2004-06-01 01:18:51 +0000 |
commit | d503c79cad595bd26f835062ce4bb6ef858857eb (patch) | |
tree | 70cc910e8da4e8552af2295511fb0f6609b4adb4 /sys/fs | |
parent | 85ad08a47d54b127e27feaec25eedac03c361093 (diff) | |
download | FreeBSD-src-d503c79cad595bd26f835062ce4bb6ef858857eb.zip FreeBSD-src-d503c79cad595bd26f835062ce4bb6ef858857eb.tar.gz |
Add MSG_NBIO flag option to soreceive() and sosend() that causes
them to behave the same as if the SS_NBIO socket flag had been set
for this call. The SS_NBIO flag for ordinary sockets is set by
fcntl(fd, F_SETFL, O_NONBLOCK).
Pass the MSG_NBIO flag to the soreceive() and sosend() calls in
fifo_read() and fifo_write() instead of frobbing the SS_NBIO flag
on the underlying socket for each I/O operation. The O_NONBLOCK
flag is a property of the descriptor, and unlike ordinary sockets,
fifos may be referenced by multiple descriptors.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/fifofs/fifo_vnops.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 0f97c17..8ecd33e 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -312,7 +312,7 @@ fifo_read(ap) struct uio *uio = ap->a_uio; struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock; struct thread *td = uio->uio_td; - int error; + int error, flags; #ifdef DIAGNOSTIC if (uio->uio_rw != UIO_READ) @@ -320,14 +320,11 @@ fifo_read(ap) #endif if (uio->uio_resid == 0) return (0); - if (ap->a_ioflag & IO_NDELAY) - rso->so_state |= SS_NBIO; VOP_UNLOCK(ap->a_vp, 0, td); + flags = (ap->a_ioflag & IO_NDELAY) ? MSG_NBIO : 0; error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0, - (struct mbuf **)0, (int *)0); + (struct mbuf **)0, &flags); vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); - if (ap->a_ioflag & IO_NDELAY) - rso->so_state &= ~SS_NBIO; return (error); } @@ -346,20 +343,17 @@ fifo_write(ap) { struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock; struct thread *td = ap->a_uio->uio_td; - int error; + int error, flags; #ifdef DIAGNOSTIC if (ap->a_uio->uio_rw != UIO_WRITE) panic("fifo_write mode"); #endif - if (ap->a_ioflag & IO_NDELAY) - wso->so_state |= SS_NBIO; VOP_UNLOCK(ap->a_vp, 0, td); + flags = (ap->a_ioflag & IO_NDELAY) ? MSG_NBIO : 0; error = sosend(wso, (struct sockaddr *)0, ap->a_uio, 0, - (struct mbuf *)0, 0, td); + (struct mbuf *)0, flags, td); vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); - if (ap->a_ioflag & IO_NDELAY) - wso->so_state &= ~SS_NBIO; return (error); } |