summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorJonathan Lemon <jlemon@FreeBSD.org>2001-06-23 06:54:28 +0000
committerJonathan Lemon <jlemon@FreeBSD.org>2001-06-23 06:54:28 +0000
commit4dd2af159e772f5a721cba33688f65bf13ad5268 (patch)
tree932d1cd580d2ef8f21858f9e0136b2780c6e92a7 /lib/libc
parent3ae3f8b0be5b6af0185e9d8d3cfc19d1fad4a0fd (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/net/res_send.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c
index 3513a4985f36..e56b91f6fc0d 100644
--- a/lib/libc/net/res_send.c
+++ b/lib/libc/net/res_send.c
@@ -598,7 +598,8 @@ read_len:
* Use datagrams.
*/
struct kevent kv;
- struct timespec timeout;
+ struct timespec ts;
+ struct timeval timeout, ctv;
struct sockaddr_storage from;
int fromlen;
@@ -707,7 +708,10 @@ read_len:
timeout.tv_sec /= _res.nscount;
if ((long) timeout.tv_sec <= 0)
timeout.tv_sec = 1;
- timeout.tv_nsec = 0;
+ timeout.tv_usec = 0;
+ TIMEVAL_TO_TIMESPEC(&timeout, &ts);
+ (void) gettimeofday(&ctv, NULL);
+ timeradd(&timeout, &ctv, &timeout);
wait:
if (s < 0) {
Perror(stderr, "s out-of-bounds", EMFILE);
@@ -717,13 +721,20 @@ read_len:
EV_SET(&kv, s, EVFILT_READ, EV_ADD | EV_ONESHOT, 0,0,0);
- n = _kevent(kq, &kv, 1, &kv, 1, &timeout);
+ n = _kevent(kq, &kv, 1, &kv, 1, &ts);
if (n < 0) {
- if (errno == EINTR)
- goto wait;
- Perror(stderr, "kevent", errno);
- res_close();
- goto next_ns;
+ if (errno == EINTR) {
+ (void) gettimeofday(&ctv, NULL);
+ if (timercmp(&ctv, &timeout, <)) {
+ timersub(&timeout, &ctv, &ctv);
+ TIMEVAL_TO_TIMESPEC(&ctv, &ts);
+ goto wait;
+ }
+ } else {
+ Perror(stderr, "kevent", errno);
+ res_close();
+ goto next_ns;
+ }
}
if (n == 0) {