From 9943c2ae44ef098f1ba3e295a7217e125bdfb91a Mon Sep 17 00:00:00 2001 From: art <> Date: Fri, 7 Jul 2000 15:34:02 +0000 Subject: If the timeout is not set, don't send a zeroed timeout to select. This solves the problem with nc hogging all cpu. --- src/usr.bin/nc/netcat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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) /* and now the big ol' select shoveling loop ... */ while (FD_ISSET(fd, &fds1)) { /* i.e. till the *net* closes! */ + struct timeval *tv; + wretry = 8200; /* more than we'll ever hafta write */ if (wfirst) { /* any saved stdin buffer? */ wfirst = 0; /* clear flag for the duration */ goto shovel; /* and go handle it first */ } fds2 = fds1; - memcpy(&timer2, &timer1, sizeof(struct timeval)); - rr = select(getdtablesize(), &fds2, 0, 0, &timer2); + if (timer1.tv_sec > 0 || timer1.tv_usec > 0) { + memcpy(&timer2, &timer1, sizeof(struct timeval)); + tv = &timer2; + } else + tv = NULL; + rr = select(getdtablesize(), &fds2, 0, 0, tv); if (rr < 0) { if (errno != EINTR) { /* might have gotten ^Zed, etc * ? */ -- cgit v1.2.3-55-g6feb