(fillcache, do_write, io_input, io_output): Portability fix: always
check both EAGAIN and EWOULDBLOCK. These are distinct on some systems, e.g. HP-UX. (io_output) [hpux]: Used to treat all errors as EWOULDBLOCK. This looks like a inept attempt to `fix' the above. Remove.
This commit is contained in:
parent
9113969208
commit
edaa05b8cb
2 changed files with 4 additions and 11 deletions
|
@ -276,7 +276,7 @@ fillcache(struct empfile *ep, int start)
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
ret = read(ep->fd, p, n);
|
ret = read(ep->fd, p, n);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||||
logerror("Error reading %s (%s)", ep->file, strerror(errno));
|
logerror("Error reading %s (%s)", ep->file, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ do_write(struct empfile *ep, void *buf, int id, int count)
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
ret = write(ep->fd, p, n);
|
ret = write(ep->fd, p, n);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||||
logerror("Error writing %s (%s)", ep->file, strerror(errno));
|
logerror("Error writing %s (%s)", ep->file, strerror(errno));
|
||||||
/* FIXME if this extended file, truncate back to old size */
|
/* FIXME if this extended file, truncate back to old size */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -147,7 +147,7 @@ io_input(struct iop *iop, int waitforinput)
|
||||||
cc = read(iop->fd, buf, sizeof(buf));
|
cc = read(iop->fd, buf, sizeof(buf));
|
||||||
if (cc < 0) {
|
if (cc < 0) {
|
||||||
/* would block, so nothing to read. */
|
/* would block, so nothing to read. */
|
||||||
if (errno == EWOULDBLOCK)
|
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Some form of file error occurred... */
|
/* Some form of file error occurred... */
|
||||||
|
@ -243,7 +243,7 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
/* if it failed.... */
|
/* if it failed.... */
|
||||||
if (cc < 0) {
|
if (cc < 0) {
|
||||||
/* Hmm, it would block. file is opened noblock, soooooo.. */
|
/* Hmm, it would block. file is opened noblock, soooooo.. */
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
/* If there are remaining bytes, set the IO as remaining.. */
|
/* If there are remaining bytes, set the IO as remaining.. */
|
||||||
remain = ioq_qsize(iop->output);
|
remain = ioq_qsize(iop->output);
|
||||||
return remain;
|
return remain;
|
||||||
|
@ -269,17 +269,10 @@ io_output(struct iop *iop, int waitforoutput)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If no bytes were written, something happened.. Like an EOF. */
|
/* If no bytes were written, something happened.. Like an EOF. */
|
||||||
#ifndef hpux
|
|
||||||
if (cc == 0) {
|
if (cc == 0) {
|
||||||
iop->flags |= IO_EOF;
|
iop->flags |= IO_EOF;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (cc == 0) {
|
|
||||||
remain = ioq_qsize(iop->output);
|
|
||||||
return remain;
|
|
||||||
}
|
|
||||||
#endif /* hpux */
|
|
||||||
|
|
||||||
/* Remove the number of written bytes from the queue. */
|
/* Remove the number of written bytes from the queue. */
|
||||||
ioq_dequeue(iop->output, cc);
|
ioq_dequeue(iop->output, cc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue