summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorart <>2000-07-07 15:34:02 +0000
committerart <>2000-07-07 15:34:02 +0000
commit9943c2ae44ef098f1ba3e295a7217e125bdfb91a (patch)
treeedd521065bae69995160539f09793205d48af311 /src
parent0b34f0026063d3c27494bb00d18f71c14a59e95a (diff)
downloadopenbsd-9943c2ae44ef098f1ba3e295a7217e125bdfb91a.tar.gz
openbsd-9943c2ae44ef098f1ba3e295a7217e125bdfb91a.tar.bz2
openbsd-9943c2ae44ef098f1ba3e295a7217e125bdfb91a.zip
If the timeout is not set, don't send a zeroed timeout to select.
This solves the problem with nc hogging all cpu.
Diffstat (limited to 'src')
-rw-r--r--src/usr.bin/nc/netcat.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index 31f49a3fc3..eb4351dbe1 100644
--- a/src/usr.bin/nc/netcat.c
+++ b/src/usr.bin/nc/netcat.c
@@ -1125,14 +1125,20 @@ readwrite(fd)
1125 1125
1126/* and now the big ol' select shoveling loop ... */ 1126/* and now the big ol' select shoveling loop ... */
1127 while (FD_ISSET(fd, &fds1)) { /* i.e. till the *net* closes! */ 1127 while (FD_ISSET(fd, &fds1)) { /* i.e. till the *net* closes! */
1128 struct timeval *tv;
1129
1128 wretry = 8200; /* more than we'll ever hafta write */ 1130 wretry = 8200; /* more than we'll ever hafta write */
1129 if (wfirst) { /* any saved stdin buffer? */ 1131 if (wfirst) { /* any saved stdin buffer? */
1130 wfirst = 0; /* clear flag for the duration */ 1132 wfirst = 0; /* clear flag for the duration */
1131 goto shovel; /* and go handle it first */ 1133 goto shovel; /* and go handle it first */
1132 } 1134 }
1133 fds2 = fds1; 1135 fds2 = fds1;
1134 memcpy(&timer2, &timer1, sizeof(struct timeval)); 1136 if (timer1.tv_sec > 0 || timer1.tv_usec > 0) {
1135 rr = select(getdtablesize(), &fds2, 0, 0, &timer2); 1137 memcpy(&timer2, &timer1, sizeof(struct timeval));
1138 tv = &timer2;
1139 } else
1140 tv = NULL;
1141 rr = select(getdtablesize(), &fds2, 0, 0, tv);
1136 if (rr < 0) { 1142 if (rr < 0) {
1137 if (errno != EINTR) { /* might have gotten ^Zed, etc 1143 if (errno != EINTR) { /* might have gotten ^Zed, etc
1138 * ? */ 1144 * ? */