aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Denys Vlasenko <vda.linux@googlemail.com>2009-08-03 03:01:29 +0200
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2009-08-03 03:01:29 +0200
commit89f022469f42895aa12ee39aeb9c84bf45a58c4c (patch)
tree187741e714b496f6cd3eff9f79d86f5a1ab5719d
parent471ca65091b4366b6b496aeda1c80d01078c8333 (diff)
downloadbusybox-89f022469f42895aa12ee39aeb9c84bf45a58c4c.tar.gz
busybox-89f022469f42895aa12ee39aeb9c84bf45a58c4c.tar.bz2
revert last commit, it was meant for master
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/nc.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/networking/nc.c b/networking/nc.c
index 1babe3bb7..fe845f582 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -172,12 +172,11 @@ int nc_main(int argc, char **argv)
testfds = readfds;
- if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0)
+ if (select(FD_SETSIZE, &testfds, NULL, NULL, NULL) < 0)
bb_perror_msg_and_die("select");
#define iobuf bb_common_bufsiz1
- fd = STDIN_FILENO;
- while (1) {
+ for (fd = 0; fd < FD_SETSIZE; fd++) {
if (FD_ISSET(fd, &testfds)) {
nread = safe_read(fd, iobuf, sizeof(iobuf));
if (fd == cfd) {
@@ -185,21 +184,17 @@ int nc_main(int argc, char **argv)
exit(EXIT_SUCCESS);
ofd = STDOUT_FILENO;
} else {
- if (nread < 1) {
- /* Close outgoing half-connection so they get EOF,
- * but leave incoming alone so we can see response */
+ if (nread<1) {
+ // Close outgoing half-connection so they get EOF, but
+ // leave incoming alone so we can see response.
shutdown(cfd, 1);
FD_CLR(STDIN_FILENO, &readfds);
}
ofd = cfd;
}
xwrite(ofd, iobuf, nread);
- if (delay > 0)
- sleep(delay);
+ if (delay > 0) sleep(delay);
}
- if (fd == cfd)
- break;
- fd = cfd;
}
}
}