Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net do not try to transmit UDP DNS query forever, i...



details:   https://anonhg.NetBSD.org/src/rev/82bbf165f44f
branches:  trunk
changeset: 495374:82bbf165f44f
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jul 27 00:35:02 2000 +0000

description:
do not try to transmit UDP DNS query forever, in EINTR-busy situation.
the change uses extra variables which can be avoided,
it is to make the change look similar to BIND8 change.
question: timeout resolution is 1 second (time_t).  should we use
timevals instead?

PR 6410 From: maximum entropy <entropy%venom.bernstein.com@localhost>

diffstat:

 lib/libc/net/res_send.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (52 lines):

diff -r 924543bd826d -r 82bbf165f44f lib/libc/net/res_send.c
--- a/lib/libc/net/res_send.c   Thu Jul 27 00:25:05 2000 +0000
+++ b/lib/libc/net/res_send.c   Thu Jul 27 00:35:02 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: res_send.c,v 1.30 2000/07/06 03:01:32 christos Exp $   */
+/*     $NetBSD: res_send.c,v 1.31 2000/07/27 00:35:02 itojun Exp $     */
 
 /*-
  * Copyright (c) 1985, 1989, 1993
@@ -59,7 +59,7 @@
 static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
 static char rcsid[] = "Id: res_send.c,v 8.13 1997/06/01 20:34:37 vixie Exp ";
 #else
-__RCSID("$NetBSD: res_send.c,v 1.30 2000/07/06 03:01:32 christos Exp $");
+__RCSID("$NetBSD: res_send.c,v 1.31 2000/07/27 00:35:02 itojun Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -627,7 +627,7 @@
                        /*
                         * Use datagrams.
                         */
-                       time_t seconds;
+                       time_t seconds, now, timeout, finish;
                        struct pollfd dsfd;
                        struct sockaddr_storage from;
                        socklen_t fromlen;
@@ -737,13 +737,21 @@
                                seconds /= _res.nscount;
                        if ((long) seconds <= 0)
                                seconds = 1;
+                       now = time(NULL);
+                       timeout = seconds;
+                       finish = now + timeout;
                        dsfd.fd = s;
                        dsfd.events = POLLIN;
 wait:
-                       n = poll(&dsfd, 1, (int)(seconds * 1000));
+                       n = poll(&dsfd, 1, (int)(timeout * 1000));
                        if (n < 0) {
-                               if (errno == EINTR)
-                                       goto wait;
+                               if (errno == EINTR) {
+                                       now = time(NULL);
+                                       if (finish > now) {
+                                               timeout = finish - now;
+                                               goto wait;
+                                       }
+                               }
                                Perror(stderr, "poll", errno);
                                res_close();
                                goto next_ns;



Home | Main Index | Thread Index | Old Index