|
@ -176,11 +176,14 @@ pump (int pullfd, int pushfd) |
|
|
r = select(maxfd+1, &readfds, &writefds, &exceptfds, NULL); |
|
|
r = select(maxfd+1, &readfds, &writefds, &exceptfds, NULL); |
|
|
|
|
|
|
|
|
if (r < 0 || FD_ISSET(pushfd, &exceptfds)) { |
|
|
if (r < 0 || FD_ISSET(pushfd, &exceptfds)) { |
|
|
|
|
|
close(pushfd); |
|
|
|
|
|
close(pullfd); |
|
|
pushfd = pullfd = -1; |
|
|
pushfd = pullfd = -1; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (pullfd >= 0 && FD_ISSET(pullfd, &exceptfds)) { |
|
|
if (pullfd >= 0 && FD_ISSET(pullfd, &exceptfds)) { |
|
|
|
|
|
close(pullfd); |
|
|
pullfd = -1; |
|
|
pullfd = -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -188,6 +191,7 @@ pump (int pullfd, int pushfd) |
|
|
r = ring_buffer_pull(&ring, pullfd); |
|
|
r = ring_buffer_pull(&ring, pullfd); |
|
|
if (r == 0) { |
|
|
if (r == 0) { |
|
|
/* eof */ |
|
|
/* eof */ |
|
|
|
|
|
close(pullfd); |
|
|
pullfd = -1; |
|
|
pullfd = -1; |
|
|
|
|
|
|
|
|
} else if (r < 0) { |
|
|
} else if (r < 0) { |
|
@ -205,6 +209,8 @@ pump (int pullfd, int pushfd) |
|
|
|
|
|
|
|
|
case EPIPE: |
|
|
case EPIPE: |
|
|
/* TODO catch SIGPIPE? */ |
|
|
/* TODO catch SIGPIPE? */ |
|
|
|
|
|
close(pushfd); |
|
|
|
|
|
close(pullfd); |
|
|
pushfd = pullfd = -1; |
|
|
pushfd = pullfd = -1; |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
@ -215,9 +221,13 @@ pump (int pullfd, int pushfd) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
close(pushfd); |
|
|
|
|
|
close(pullfd); |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
error: |
|
|
error: |
|
|
|
|
|
close(pushfd); |
|
|
|
|
|
close(pullfd); |
|
|
perror("(coupling) pump"); |
|
|
perror("(coupling) pump"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|