From: Philipp Tölke Date: Tue, 20 Jul 2010 11:36:45 +0000 (+0000) Subject: Handle EOF in the stream between daemon and helper X-Git-Tag: initial-import-from-subversion-38251~20907 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9cc6fe559312bf93a47bf19a019fef8c4f952f54;p=oweals%2Fgnunet.git Handle EOF in the stream between daemon and helper --- diff --git a/src/vpn/gnunet-vpn-helper.c b/src/vpn/gnunet-vpn-helper.c index 928ede4c6..0cb5937a4 100644 --- a/src/vpn/gnunet-vpn-helper.c +++ b/src/vpn/gnunet-vpn-helper.c @@ -143,7 +143,7 @@ int main(int argc, char** argv) { int write_fd_possible = 0; int write_stdout_possible = 0; outer: - while(rea != 0 && wri != 0 && running == 1) { + while((rea == 1 || wri == 1) && running == 1) { FD_ZERO(&fds_w); FD_ZERO(&fds_r); @@ -169,7 +169,7 @@ outer: write_fd_possible = 0; struct suid_packet *pkt = (struct suid_packet*) buf; r = read(0, buf, sizeof(struct suid_packet_header)); - if (r < 0) { + if (r <= 0) { fprintf(stderr, "read-error: %m\n"); shutdown(fd_tun, SHUT_WR); shutdown(0, SHUT_RD); @@ -202,7 +202,7 @@ outer: } else if (write_stdout_possible && FD_ISSET(fd_tun, &fds_r)) { write_stdout_possible = 0; r = read(fd_tun, buf, 65600); - if (r < 0) { + if (r <= 0) { fprintf(stderr, "read-error: %m\n"); shutdown(fd_tun, SHUT_RD); shutdown(1, SHUT_WR);