chiark / gitweb /
+ Bugfixes:
authorian <ian>
Sun, 26 Mar 2000 15:02:09 +0000 (15:02 +0000)
committerian <ian>
Sun, 26 Mar 2000 15:02:09 +0000 (15:02 +0000)
@@ -1,13 +1,26 @@
 uadns (0.8) BETA; urgency=low

+  Bugfixes:
   * Spurious `server failure on unidentifiable query' warning suppressed.
-  * install-sh (from autoconf 2.12 Debian r13) included.
   * adnslogres: cast chars to unsigned char before using ctype.h macros.
+  * In _beforeselect, global failure now means zero timeout, and in
+    tcp_events, really never try to do anything with the TCP connection if
+    act is zero.  This might possibly cause an infinite delay (ie, lockup)
+    if things go badly wrong *and* a really unlikely race happens.
+  * Test suite `lines of syscall left' value is correct; !0 is failure.
+
+  Portability fixes:
+  * install-sh (from autoconf 2.12 Debian r13) included.
+
+  Documentation improvements:
   * Security/performance note added, about local nameservers and DNSSEC.
   * Documented that adns_rr_info _rr_hostaddr ( ) for address list
     means permanent failure, and ? means temporary failure.
   * Typo (*now for now in _beforeselect description) in adns.h fixed.
-  * In _beforeselect, global system failure now produces zero timeout.
+
+  Changes to produce more defensive code:
+  * In adns_wait, assert that the timeout is not infinite.
+  * Make qu->id start out as -2 when initially allocated.

  --

changelog
regress/hplayback.c.m4
regress/r1test
src/event.c
src/internal.h
src/query.c

index a6fe1958f93363dae185b8c3dda75a2ef5fe9824..d7868bbbea5d261d4bc6aa9b0351d3507243df40 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,13 +1,26 @@
 uadns (0.8) BETA; urgency=low
 
+  Bugfixes:
   * Spurious `server failure on unidentifiable query' warning suppressed.
-  * install-sh (from autoconf 2.12 Debian r13) included.
   * adnslogres: cast chars to unsigned char before using ctype.h macros.
+  * In _beforeselect, global failure now means zero timeout, and in
+    tcp_events, really never try to do anything with the TCP connection if
+    act is zero.  This might possibly cause an infinite delay (ie, lockup)
+    if things go badly wrong *and* a really unlikely race happens.
+  * Test suite `lines of syscall left' value is correct; !0 is failure.
+
+  Portability fixes:
+  * install-sh (from autoconf 2.12 Debian r13) included.
+
+  Documentation improvements:
   * Security/performance note added, about local nameservers and DNSSEC.
   * Documented that adns_rr_info _rr_hostaddr ( ) for address list
     means permanent failure, and ? means temporary failure.
   * Typo (*now for now in _beforeselect description) in adns.h fixed.
-  * In _beforeselect, global system failure now produces zero timeout.
+  
+  Changes to produce more defensive code:
+  * In adns_wait, assert that the timeout is not infinite.
+  * Make qu->id start out as -2 when initially allocated.
 
  --
 
index 97e951a33665878636c51beb902d2bd1be2c77a8..01e60db9373cd42550a3648a4c73baad4e494cb8 100644 (file)
@@ -78,6 +78,7 @@ static void Tensureinputfile(void) {
     fd= atoi(fdstr);
     Tinputfile= fdopen(fd,"r"); if (!Tinputfile) Tfailed("fdopen ADNS_TEST_IN_FD");
   }
+  setvbuf(Tinputfile,0,_IONBF,0);
 
   if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
   fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
index de8db693792b16d66d7f659d0ec9b55d3e4c629f..4315bf8a77699f65b51400b6bf63f2e6101d2745 100755 (executable)
@@ -42,13 +42,20 @@ do
        then
                :
        else
-               failed=true
+               failwhy="$failwhy WRONG OUTPUT"
        fi
 done
 
-if $failed
+cat >"$ocase.leftover"
+if egrep . /dev/null "$ocase.leftover"
 then
-       echo >&2 "FAILED $case - WRONG OUTPUT - lines of syscall remaining `wc -l`"
+       failwhy="$failwhy EXITED EARLY"
+fi
+
+if [ "x$failwhy" != x ]
+then
+       scremain="`wc -l <\"$ocase.leftover\"`"
+       echo >&2 "FAILED $case -$failwhy - lines of syscall remaining $scremain"
        mrc=2
        exit
 fi
index 7c610c7d2100332cc6c25990c3dbee7df9580747..885ab81032747cb4ba478c84723375fa2791f73c 100644 (file)
@@ -143,6 +143,17 @@ void adns__must_gettimeofday(adns_state ads, const struct timeval **now_io,
   return;
 }
 
+static void inter_immed(struct timeval **tv_io, struct timeval *tvbuf) {
+  struct timeval *rbuf;
+
+  if (!tv_io) return;
+
+  rbuf= *tv_io;
+  if (!rbuf) { *tv_io= rbuf= tvbuf; }
+
+  timerclear(rbuf);
+}
+    
 static void inter_maxto(struct timeval **tv_io, struct timeval *tvbuf,
                        struct timeval maxto) {
   struct timeval *rbuf;
@@ -185,12 +196,7 @@ static void timeouts_queue(adns_state ads, int act,
     if (!timercmp(&now,&qu->timeout,>)) {
       inter_maxtoabs(tv_io,tvbuf,now,qu->timeout);
     } else {
-      if (!act) {
-       tvbuf->tv_sec= 0;
-       tvbuf->tv_usec= 0;
-       *tv_io= tvbuf;
-       return;
-      }
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
       LIST_UNLINK(*queue,qu);
       if (qu->state != query_tosend) {
        adns__query_fail(qu,adns_s_timeout);
@@ -210,6 +216,7 @@ static void tcp_events(adns_state ads, int act,
   for (;;) {
     switch (ads->tcpstate) {
     case server_broken:
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
       for (qu= ads->tcpw.head; qu; qu= nqu) {
        nqu= qu->next;
        assert(qu->state == query_tcpw);
@@ -221,6 +228,7 @@ static void tcp_events(adns_state ads, int act,
       ads->tcpstate= server_disconnected;
     case server_disconnected: /* fall through */
       if (!ads->tcpw.head) return;
+      if (!act) { inter_immed(tv_io,tvbuf); return; }
       adns__tcp_tryconnect(ads,now);
       break;
     case server_ok:
@@ -231,7 +239,7 @@ static void tcp_events(adns_state ads, int act,
        timevaladd(&ads->tcptimeout,TCPIDLEMS);
       }
     case server_connecting: /* fall through */
-      if (!timercmp(&now,&ads->tcptimeout,>)) {
+      if (!act || !timercmp(&now,&ads->tcptimeout,>)) {
        inter_maxtoabs(tv_io,tvbuf,now,ads->tcptimeout);
        return;
       } {
@@ -253,6 +261,7 @@ static void tcp_events(adns_state ads, int act,
       abort();
     }
   }
+  return;
 }
 
 void adns__timeouts(adns_state ads, int act,
@@ -665,6 +674,7 @@ int adns_wait(adns_state ads,
     maxfd= 0; tvp= 0;
     FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
     adns_beforeselect(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf,0);
+    assert(tvp);
     rsel= select(maxfd,&readfds,&writefds,&exceptfds,tvp);
     if (rsel==-1) {
       if (errno == EINTR) {
index 643b86f00ad18eb0b0b4ab52791bcc8ef33e010f..c7667382babd3adfec53dfde1e92e641c387c5d8 100644 (file)
@@ -289,10 +289,10 @@ struct adns__state {
     server_ok, server_broken
   } tcpstate;
   struct timeval tcptimeout;
-  /* This will have tv_sec==0 if it is not valid.
-   * It will always be valid if tcpstate _connecting.
-   * When _ok, it will be nonzero if we are idle
-   * (ie, tcpw queue is empty) and counting down.
+  /* This will have tv_sec==0 if it is not valid.  It will always be
+   * valid if tcpstate _connecting.  When _ok, it will be nonzero if
+   * we are idle (ie, tcpw queue is empty), in which case it is the
+   * absolute time when we will close the connection.
    */
   struct sigaction stdsigpipe;
   sigset_t stdsigmask;
index a8423d7c36e3a7bdd6c13c104885d83a10a5bcf3..aaadb219e8868134d2882fb36e5f99872949b2e4 100644 (file)
@@ -66,7 +66,7 @@ static adns_query query_alloc(adns_state ads, const typeinfo *typei,
   adns__vbuf_init(&qu->search_vb);
   qu->search_origlen= qu->search_pos= qu->search_doneabs= 0;
 
-  qu->id= 0;
+  qu->id= -2; /* will be overwritten with real id before we leave adns */
   qu->flags= flags;
   qu->retries= 0;
   qu->udpnextserver= 0;