diff options
| author | Jonathan Lemon <jlemon@FreeBSD.org> | 2000-03-26 19:20:50 +0000 |
|---|---|---|
| committer | Jonathan Lemon <jlemon@FreeBSD.org> | 2000-03-26 19:20:50 +0000 |
| commit | 613483782407aac11184b979c0c15356d68329ec (patch) | |
| tree | aa6a0746e8a2f75c9f57aac43c980b2c8e8f89de /lib/libc/net/res_send.c | |
| parent | b10e6acec42d2878e63f5b6ed31d99a0875979be (diff) | |
Notes
Diffstat (limited to 'lib/libc/net/res_send.c')
| -rw-r--r-- | lib/libc/net/res_send.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index 68a7c60e0aab..895db8110bd2 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -635,11 +635,17 @@ read_len: #ifndef NOPOLL othersyscall: if (use_poll) { + struct timeval itv; + msec = (_res.retrans << try) * 1000; if (try > 0) msec /= _res.nscount; if (msec <= 0) msec = 1000; + gettimeofday(&timeout, NULL); + itv.tv_sec = msec / 1000; + itv.tv_usec = (msec % 1000) * 1000; + timeradd(&timeout, &itv, &timeout); } else { #endif timeout.tv_sec = (_res.retrans << try); @@ -685,11 +691,22 @@ read_len: } else if (use_poll == 1) use_poll = 2; if (n < 0) { - if (errno == EINTR) - goto wait; - Perror(stderr, "poll", errno); - res_close(); - goto next_ns; + if (errno == EINTR) { + struct timeval ctv; + + gettimeofday(&ctv, NULL); + if (timercmp(&ctv, &timeout, <)) { + timersub(&timeout, + &ctv, &ctv); + msec = ctv.tv_sec * 1000; + msec += ctv.tv_usec / 1000; + goto wait; + } + } else { + Perror(stderr, "poll", errno); + res_close(); + goto next_ns; + } } } else { #endif |
