rc: make read not ignore interrupts/errors (again)
http://codereview.appspot.com/110042
This commit is contained in:
parent
375b78fb11
commit
e066b12927
1 changed files with 7 additions and 2 deletions
|
|
@ -222,8 +222,11 @@ readnb(int fd, char *buf, long cnt)
|
||||||
int flgs;
|
int flgs;
|
||||||
|
|
||||||
didreset = 0;
|
didreset = 0;
|
||||||
while((n = read(fd, buf, cnt)) == -1)
|
again:
|
||||||
if(!didreset && errno == EAGAIN){
|
n = read(fd, buf, cnt);
|
||||||
|
if(n == -1)
|
||||||
|
if(errno == EAGAIN){
|
||||||
|
if(!didreset){
|
||||||
if((flgs = fcntl(fd, F_GETFL, 0)) == -1)
|
if((flgs = fcntl(fd, F_GETFL, 0)) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
flgs &= ~O_NONBLOCK;
|
flgs &= ~O_NONBLOCK;
|
||||||
|
|
@ -231,6 +234,8 @@ readnb(int fd, char *buf, long cnt)
|
||||||
return -1;
|
return -1;
|
||||||
didreset = 1;
|
didreset = 1;
|
||||||
}
|
}
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue