chiark / gitweb /
Retransmission and timeout work now !
authorian <ian>
Sun, 4 Oct 1998 16:38:52 +0000 (16:38 +0000)
committerian <ian>
Sun, 4 Oct 1998 16:38:52 +0000 (16:38 +0000)
src/event.c
src/internal.h
src/query.c
src/setup.c
src/submit.c

index 14ce1b03f6150a8811a22b2be30340323860b4ab..7ed12f646b04475400f02f3ad009e76b322c658f 100644 (file)
@@ -98,20 +98,28 @@ static void inter_maxto(struct timeval **tv_io, struct timeval *tvbuf,
 
   if (!tv_io) return;
   rbuf= *tv_io;
 
   if (!tv_io) return;
   rbuf= *tv_io;
-  if (!rbuf) { *tvbuf= maxto; *tv_io= tvbuf; return; }
-  if (timercmp(rbuf,&maxto,>)) *rbuf= maxto;
+  if (!rbuf) {
+    *tvbuf= maxto; *tv_io= tvbuf;
+  } else {
+    if (timercmp(rbuf,&maxto,>)) *rbuf= maxto;
+  }
+fprintf(stderr,"inter_maxto maxto=%ld.%06ld result=%ld.%06ld\n",
+       maxto.tv_sec,maxto.tv_usec,(**tv_io).tv_sec,(**tv_io).tv_usec);
 }
 
 static void inter_maxtoabs(struct timeval **tv_io, struct timeval *tvbuf,
                           struct timeval now, struct timeval maxtime) {
   ldiv_t dr;
 
 }
 
 static void inter_maxtoabs(struct timeval **tv_io, struct timeval *tvbuf,
                           struct timeval now, struct timeval maxtime) {
   ldiv_t dr;
 
+fprintf(stderr,"inter_maxtoabs now=%ld.%06ld maxtime=%ld.%06ld\n",
+       now.tv_sec,now.tv_usec,maxtime.tv_sec,maxtime.tv_usec);
   if (!tv_io) return;
   if (!tv_io) return;
-  maxtime.tv_sec -= (now.tv_sec-1);
-  maxtime.tv_usec += (1000-now.tv_usec);
-  dr= ldiv(maxtime.tv_usec,1000);
+  maxtime.tv_sec -= (now.tv_sec+2);
+  maxtime.tv_usec -= (now.tv_usec-2000000);
+  dr= ldiv(maxtime.tv_usec,1000000);
   maxtime.tv_sec += dr.quot;
   maxtime.tv_sec += dr.quot;
-  maxtime.tv_usec -= dr.rem;
+  maxtime.tv_usec -= dr.quot*1000000;
+  if (maxtime.tv_sec<0) timerclear(&maxtime);
   inter_maxto(tv_io,tvbuf,maxtime);
 }
 
   inter_maxto(tv_io,tvbuf,maxtime);
 }
 
@@ -147,7 +155,9 @@ void adns_interest(adns_state ads, int *maxfd,
   struct timeval tvto_lr;
   int r;
   
   struct timeval tvto_lr;
   int r;
   
-  r= gettimeofday(&now,0);
+fprintf(stderr,"adns_interest\n");
+
+r= gettimeofday(&now,0);
   if (r) {
     adns__warn(ads,-1,"gettimeofday failed - will sleep for a bit: %s",strerror(errno));
     timerclear(&tvto_lr); timevaladd(&tvto_lr,LOCALRESOURCEMS);
   if (r) {
     adns__warn(ads,-1,"gettimeofday failed - will sleep for a bit: %s",strerror(errno));
     timerclear(&tvto_lr); timevaladd(&tvto_lr,LOCALRESOURCEMS);
@@ -352,7 +362,7 @@ int adns_wait(adns_state ads,
   
   for (;;) {
     r= internal_check(ads,query_io,answer_r,context_r);
   
   for (;;) {
     r= internal_check(ads,query_io,answer_r,context_r);
-    if (r && r != EWOULDBLOCK) return r;
+    if (r != EWOULDBLOCK) return r;
     maxfd= 0; tvp= 0;
     FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
     adns_interest(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf);
     maxfd= 0; tvp= 0;
     FD_ZERO(&readfds); FD_ZERO(&writefds); FD_ZERO(&exceptfds);
     adns_interest(ads,&maxfd,&readfds,&writefds,&exceptfds,&tvp,&tvbuf);
index b652f2304903d4cd4c44d0e8bfb5d80643136ef7..5b5097b7ed6b21abd81872621f67f254d5e24721 100644 (file)
@@ -17,7 +17,7 @@ typedef unsigned char byte;
 /* Configuration and constants */
 
 #define MAXSERVERS 5
 /* Configuration and constants */
 
 #define MAXSERVERS 5
-#define MAXUDPRETRIES 15
+#define MAXUDPRETRIES /*15*/5
 #define UDPRETRYMS 2000
 #define TCPMS 30000
 #define LOCALRESOURCEMS 20
 #define UDPRETRYMS 2000
 #define TCPMS 30000
 #define LOCALRESOURCEMS 20
@@ -175,9 +175,9 @@ static inline void timevaladd(struct timeval *tv_io, long ms) {
   struct timeval tmp;
   assert(ms>=0);
   tmp= *tv_io;
   struct timeval tmp;
   assert(ms>=0);
   tmp= *tv_io;
-  tmp.tv_usec += (ms%1000)*1000;
+  tmp.tv_usec += (ms%1000)*1000000;
   tmp.tv_sec += ms/1000;
   tmp.tv_sec += ms/1000;
-  if (tmp.tv_usec >= 1000) { tmp.tv_sec++; tmp.tv_usec -= 1000; }
+  if (tmp.tv_usec >= 1000000) { tmp.tv_sec++; tmp.tv_usec -= 1000; }
   *tv_io= tmp;
 }
 
   *tv_io= tmp;
 }
 
index 8aef53282a4641c201c37c03c7a1ba8fca087a52..35269e967c9acf47b87f1c88b95204192552c315 100644 (file)
@@ -17,7 +17,7 @@ adns_status adns__mkquery(adns_state ads, const char *owner, int ol, int id,
 #define MKQUERY_ADDB(b) *rqp++= (b)
 #define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
 
 #define MKQUERY_ADDB(b) *rqp++= (b)
 #define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
 
-  if (!adns__vbuf_ensure(&ads->rqbuf,12+strlen(owner)+3)) return adns_s_nolocalmem;
+  if (!adns__vbuf_ensure(&ads->rqbuf,12+strlen(owner)+1+5)) return adns_s_nolocalmem;
   rqp= ads->rqbuf.buf;
 
   MKQUERY_ADDW(id);
   rqp= ads->rqbuf.buf;
 
   MKQUERY_ADDW(id);
@@ -67,7 +67,7 @@ adns_status adns__mkquery(adns_state ads, const char *owner, int ol, int id,
   MKQUERY_ADDW(1); /* QCLASS=IN */
 
   ads->rqbuf.used= rqp - ads->rqbuf.buf;
   MKQUERY_ADDW(1); /* QCLASS=IN */
 
   ads->rqbuf.used= rqp - ads->rqbuf.buf;
-  assert(ads->rqbuf.used < ads->rqbuf.avail);
+  assert(ads->rqbuf.used <= ads->rqbuf.avail);
   
   return adns_s_ok;
 }
   
   return adns_s_ok;
 }
index 463779d5c2625d73bd0703e3c2782e6b52d9ec88..a83b97a9eafc7f89addca19af6df29c5ac3a6fd3 100644 (file)
@@ -132,16 +132,16 @@ static void ccf_nameserver(adns_state ads, const char *fn, int lno, const char *
 
 static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf) {
   if (!buf) return;
 
 static void ccf_search(adns_state ads, const char *fn, int lno, const char *buf) {
   if (!buf) return;
-  adns__diag(ads,-1,"warning - `search' ignored FIXME");
+  adns__diag(ads,-1,"warning - `search' ignored fixme");
 }
 
 static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf) {
 }
 
 static void ccf_sortlist(adns_state ads, const char *fn, int lno, const char *buf) {
-  adns__diag(ads,-1,"warning - `sortlist' ignored FIXME");
+  adns__diag(ads,-1,"warning - `sortlist' ignored fixme");
 }
 
 static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf) {
   if (!buf) return;
 }
 
 static void ccf_options(adns_state ads, const char *fn, int lno, const char *buf) {
   if (!buf) return;
-  adns__diag(ads,-1,"warning - `options' ignored FIXME");
+  adns__diag(ads,-1,"warning - `options' ignored fixme");
 }
 
 static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf) {
 }
 
 static void ccf_clearnss(adns_state ads, const char *fn, int lno, const char *buf) {
@@ -289,16 +289,19 @@ int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
   ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
   if (ads->udpsocket<0) { r= errno; goto x_free; }
 
   ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
   if (ads->udpsocket<0) { r= errno; goto x_free; }
 
-  /*fixme: nonblock */
+  r= adns__setnonblock(ads,ads->udpsocket);
+  if (r) { r= errno; goto x_closeudp; }
   
   *ads_r= ads;
   return 0;
 
   
   *ads_r= ads;
   return 0;
 
+ x_closeudp:
+  close(ads->udpsocket);
  x_free:
   free(ads);
   return r;
 }
 
 int adns_finish(adns_state ads) {
  x_free:
   free(ads);
   return r;
 }
 
 int adns_finish(adns_state ads) {
-  abort(); /* FIXME */
+  abort(); /* fixme */
 }
 }
index ea10ab8953f4dc924288e77353d673c609b21154..d0867de3b44590a3e0975408937bda7a10654bd8 100644 (file)
@@ -72,7 +72,7 @@ int adns_submit(adns_state ads,
   stat= adns__mkquery(ads,owner,ol,id,type,flags);
   if (stat) return failsubmit(ads,context,query_r,type,flags,id,stat);
 
   stat= adns__mkquery(ads,owner,ol,id,type,flags);
   if (stat) return failsubmit(ads,context,query_r,type,flags,id,stat);
 
-  qu= allocquery(ads,owner,ol,id,type,flags,context); if (!qu) return errno;
+  qu= allocquery(ads,owner,ol,id,type,flags,&ctx); if (!qu) return errno;
   adns__query_udp(ads,qu,now);
   adns__autosys(ads,now);
 
   adns__query_udp(ads,qu,now);
   adns__autosys(ads,now);
 
@@ -99,5 +99,5 @@ int adns_synchronous(adns_state ads,
 }
 
 void adns_cancel(adns_state ads, adns_query query) {
 }
 
 void adns_cancel(adns_state ads, adns_query query) {
-  abort(); /* FIXME */
+  abort(); /* fixme */
 }
 }