mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 08:22:44 +00:00
Fixed EOF handing.
1. SS_CANTRCVMORE was initially set on the wrong socket, so reads when there has never been a writer on the socket did not return 0. Note that such reads are only possible if the fifo was opened in (O_RDONLY | O_NONBLOCK) mode. 2. SS_CANTSENDMORE was initially set on the wrong socket, but this was harmless because the wrong socket is never sent from and there is no need to set the flag initially on the right socket (since open in (O_WRONLY | O_NONBLOCK) mode fails if there is no reader...). 3. SS_CANTRCVMORE was cleared when read() returns. This broke the case where read() returns 0 - subsequent reads are supposed to return 0 until a writer appears. There is no need to clear the flag when read() returns, since it is cleared correctly when a writer appears.
This commit is contained in:
parent
5fb0d3e0b3
commit
80987b7a3b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31701
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
|
||||
* $Id: fifo_vnops.c,v 1.38 1997/12/05 19:55:46 bde Exp $
|
||||
* $Id: fifo_vnops.c,v 1.39 1997/12/13 12:58:09 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -189,8 +189,7 @@ fifo_open(ap)
|
||||
return (error);
|
||||
}
|
||||
fip->fi_readers = fip->fi_writers = 0;
|
||||
wso->so_state |= SS_CANTRCVMORE;
|
||||
rso->so_state |= SS_CANTSENDMORE;
|
||||
rso->so_state |= SS_CANTRCVMORE;
|
||||
}
|
||||
if (ap->a_mode & FREAD) {
|
||||
fip->fi_readers++;
|
||||
@ -272,11 +271,6 @@ fifo_read(ap)
|
||||
error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0,
|
||||
(struct mbuf **)0, (int *)0);
|
||||
vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
/*
|
||||
* Clear EOF indication after first such return.
|
||||
*/
|
||||
if (uio->uio_resid == startresid)
|
||||
rso->so_state &= ~SS_CANTRCVMORE;
|
||||
if (ap->a_ioflag & IO_NDELAY)
|
||||
rso->so_state &= ~SS_NBIO;
|
||||
return (error);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
|
||||
* $Id: fifo_vnops.c,v 1.38 1997/12/05 19:55:46 bde Exp $
|
||||
* $Id: fifo_vnops.c,v 1.39 1997/12/13 12:58:09 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -189,8 +189,7 @@ fifo_open(ap)
|
||||
return (error);
|
||||
}
|
||||
fip->fi_readers = fip->fi_writers = 0;
|
||||
wso->so_state |= SS_CANTRCVMORE;
|
||||
rso->so_state |= SS_CANTSENDMORE;
|
||||
rso->so_state |= SS_CANTRCVMORE;
|
||||
}
|
||||
if (ap->a_mode & FREAD) {
|
||||
fip->fi_readers++;
|
||||
@ -272,11 +271,6 @@ fifo_read(ap)
|
||||
error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0,
|
||||
(struct mbuf **)0, (int *)0);
|
||||
vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
/*
|
||||
* Clear EOF indication after first such return.
|
||||
*/
|
||||
if (uio->uio_resid == startresid)
|
||||
rso->so_state &= ~SS_CANTRCVMORE;
|
||||
if (ap->a_ioflag & IO_NDELAY)
|
||||
rso->so_state &= ~SS_NBIO;
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user