chiark / gitweb /
Restarting a TCP-using query doesn't abort.
authorian <ian>
Thu, 29 Jul 1999 22:16:10 +0000 (22:16 +0000)
committerian <ian>
Thu, 29 Jul 1999 22:16:10 +0000 (22:16 +0000)
changelog
src/event.c
src/internal.h
src/query.c
src/reply.c
src/transmit.c

index 1f1162fe94c27aef1eb6f9def2be47e09c08df3f..d5ad12d4349ead7b795992d66e4e50763b91cb9b 100644 (file)
--- a/changelog
+++ b/changelog
@@ -7,6 +7,7 @@ adns (0.4) unstable; urgency=low
   * adns_s_systemfail is in table of errors (for eg adns_strerror).
   * Improvements to install instructions, TODO, etc.
   * Changed memory semantics of internal queries to fix bugs.
+  * Restarting a TCP-using query doesn't abort.
 
  --
 
index adb808b6709e0b73a9d1cd66d3e95c69f94477be..9e87429007404a87a44b0b4c639c21f314cfbcc7 100644 (file)
@@ -59,7 +59,7 @@ void adns__tcp_broken(adns_state ads, const char *what, const char *why) {
   
   for (qu= ads->timew.head; qu; qu= nqu) {
     nqu= qu->next;
-    if (qu->state == query_udp) continue;
+    if (qu->state == query_tosend) continue;
     assert(qu->state == query_tcpwait || qu->state == query_tcpsent);
     qu->state= query_tcpwait;
     qu->tcpfailed |= (1<<serv);
@@ -77,7 +77,7 @@ static void tcp_connected(adns_state ads, struct timeval now) {
   ads->tcpstate= server_ok;
   for (qu= ads->timew.head; qu; qu= nqu) {
     nqu= qu->next;
-    if (qu->state == query_udp) continue;
+    if (qu->state == query_tosend) continue;
     assert (qu->state == query_tcpwait);
     adns__query_tcp(qu,now);
   }
@@ -179,10 +179,10 @@ void adns__timeouts(adns_state ads, int act,
     } else {
       if (!act) continue;
       LIST_UNLINK(ads->timew,qu);
-      if (qu->state != query_udp) {
+      if (qu->state != query_tosend) {
        adns__query_fail(qu,adns_s_timeout);
       } else {
-       adns__query_udp(qu,now);
+       adns__query_send(qu,now);
       }
       nqu= ads->timew.head;
     }
index fc4fe853685300125d0202028f1260c34296123b..7ee8671fbc2967f2b3575e22a4e405602d3c2aca 100644 (file)
@@ -151,7 +151,7 @@ typedef struct {
 
 struct adns__query {
   adns_state ads;
-  enum { query_udp, query_tcpwait, query_tcpsent, query_child, query_done } state;
+  enum { query_tosend, query_tcpwait, query_tcpsent, query_child, query_done } state;
   adns_query back, next, parent;
   struct { adns_query head, tail; } children;
   struct { adns_query back, next; } siblings;
@@ -207,9 +207,9 @@ struct adns__query {
    *
    *  state   Queue   child  id   nextudpserver  sentudp     failedtcp
    *                             
-   *  udp     NONE    null   >=0  0              zero        zero
-   *  udp     timew   null   >=0  any            nonzero     zero
-   *  udp     NONE    null   >=0  any            nonzero     zero
+   *  tosend  NONE    null   >=0  0              zero        zero
+   *  tosend  timew   null   >=0  any            nonzero     zero
+   *  tosend  NONE    null   >=0  any            nonzero     zero
    *                             
    *  tcpwait timew   null   >=0  irrelevant     zero        any
    *  tcpsent timew   null   >=0  irrelevant     zero        any
@@ -364,11 +364,14 @@ void adns__query_tcp(adns_query qu, struct timeval now);
  * reestablishment and retry.
  */
 
-void adns__query_udp(adns_query qu, struct timeval now);
-/* Query must be in state udp/NONE; it will be moved to a new state,
+void adns__query_send(adns_query qu, struct timeval now);
+/* Query must be in state tosend/NONE; it will be moved to a new state,
  * and no further processing can be done on it for now.
  * (Resulting state is one of udp/timew, tcpwait/timew (if server not connected),
  *  tcpsent/timew, child/childw or done/output.)
+ * __query_send may decide to use either UDP or TCP depending whether
+ * _qf_usevc is set (or has become set) and whether the query is too
+ * large.
  */
 
 /* From query.c: */
index 12bd6ada4bc2d212114b836940943e23610a726e..3fab80c02f06f37cb2d897669642e52222d8c1b4 100644 (file)
@@ -42,7 +42,7 @@ static adns_query query_alloc(adns_state ads, const typeinfo *typei,
   qu->answer= malloc(sizeof(*qu->answer));  if (!qu->answer) { free(qu); return 0; }
   
   qu->ads= ads;
-  qu->state= query_udp;
+  qu->state= query_tosend;
   qu->back= qu->next= qu->parent= 0;
   LIST_INIT(qu->children);
   LINK_INIT(qu->siblings);
@@ -100,7 +100,7 @@ static void query_submit(adns_state ads, adns_query qu,
   qu->query_dglen= qu->vb.used;
   memcpy(qu->query_dgram,qu->vb.buf,qu->vb.used);
   
-  adns__query_udp(qu,now);
+  adns__query_send(qu,now);
   adns__autosys(ads,now);
 }
 
@@ -363,7 +363,7 @@ static void free_query_allocs(adns_query qu) {
 
 void adns_cancel(adns_query qu) {
   switch (qu->state) {
-  case query_udp: case query_tcpwait: case query_tcpsent:
+  case query_tosend: case query_tcpwait: case query_tcpsent:
     LIST_UNLINK(qu->ads->timew,qu);
     break;
   case query_child:
index fbc2c830cefa5ae8f9b1a48ac5a011dbd3d37256..96e43edca4d4b004e07c376b5b46c9388c70a783 100644 (file)
@@ -320,7 +320,6 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
   qu->flags |= adns_qf_usevc;
   
  x_restartquery:
-  
   if (qu->cname_dgram) {
     st= adns__mkquery_frdgram(qu->ads,&qu->vb,&qu->id,
                              qu->cname_dgram, qu->cname_dglen, qu->cname_begin,
@@ -335,6 +334,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen,
     memcpy(newquery,qu->vb.buf,qu->vb.used);
   }
   
+  if (qu->state == query_tcpsent) qu->state= query_tosend;
   adns__reset_preserved(qu);
-  adns__query_udp(qu,now);
+  adns__query_send(qu,now);
 }
index e373b48c77bdb010f0f1ac9a451af939f98aac33..33a8cc2e4254d6285b301c87fc6467ee06626ef8 100644 (file)
@@ -211,12 +211,12 @@ static void query_usetcp(adns_query qu, struct timeval now) {
   adns__tcp_tryconnect(qu->ads,now);
 }
 
-void adns__query_udp(adns_query qu, struct timeval now) {
+void adns__query_send(adns_query qu, struct timeval now) {
   struct sockaddr_in servaddr;
   int serv, r;
   adns_state ads;
 
-  assert(qu->state == query_udp);
+  assert(qu->state == query_tosend);
   if ((qu->flags & adns_qf_usevc) || (qu->query_dglen > DNS_MAXUDP)) {
     query_usetcp(qu,now);
     return;