chiark / gitweb /
+ * Add documentation comment by definition of adns_r_ptr_raw type enum.
[adns.git] / src / transmit.c
index 7ae2464d4537c55a63072a04c54290eb41aec4e2..b0a0cdde76f314da6b0107aea16aed515e3db2b8 100644 (file)
@@ -9,7 +9,7 @@
  *
  *  It is part of adns, which is
  *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999 Tony Finch <dot@dotat.at>
+ *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -39,7 +39,8 @@
 #define MKQUERY_ADDW(w) (MKQUERY_ADDB(((w)>>8)&0x0ff), MKQUERY_ADDB((w)&0x0ff))
 #define MKQUERY_STOP(vb) ((vb)->used= rqp-(vb)->buf)
 
-static adns_status mkquery_header(adns_state ads, vbuf *vb, int *id_r, int qdlen) {
+static adns_status mkquery_header(adns_state ads, vbuf *vb,
+                                 int *id_r, int qdlen) {
   int id;
   byte *rqp;
   
@@ -95,7 +96,9 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
        if (!(flags & adns_qf_quoteok_query)) return adns_s_querydomaininvalid;
        if (ctype_digit(p[0])) {
          if (ctype_digit(p[1]) && ctype_digit(p[2])) {
-           c= (*p++ - '0')*100 + (*p++ - '0')*10 + (*p++ - '0');
+           c= (*p++ - '0')*100;
+           c += (*p++ - '0')*10;
+           c += (*p++ - '0');
            if (c >= 256) return adns_s_querydomaininvalid;
          } else {
            return adns_s_querydomaininvalid;
@@ -131,7 +134,8 @@ adns_status adns__mkquery(adns_state ads, vbuf *vb, int *id_r,
 }
 
 adns_status adns__mkquery_frdgram(adns_state ads, vbuf *vb, int *id_r,
-                                 const byte *qd_dgram, int qd_dglen, int qd_begin,
+                                 const byte *qd_dgram, int qd_dglen,
+                                 int qd_begin,
                                  adns_rrtype type, adns_queryflags flags) {
   byte *rqp;
   findlabel_state fls;
@@ -174,7 +178,8 @@ void adns__querysend_tcp(adns_query qu, struct timeval now) {
   length[1]= (qu->query_dglen&0x0ff);
 
   ads= qu->ads;
-  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2)) return;
+  if (!adns__vbuf_ensure(&ads->tcpsend,ads->tcpsend.used+qu->query_dglen+2))
+    return;
 
   qu->retries++;
 
@@ -208,7 +213,8 @@ void adns__querysend_tcp(adns_query qu, struct timeval now) {
     wr-= 2;
   }
   if (wr<qu->query_dglen) {
-    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr); assert(r);
+    r= adns__vbuf_append(&ads->tcpsend,qu->query_dgram+wr,qu->query_dglen-wr);
+    assert(r);
   }
 }
 
@@ -247,8 +253,13 @@ void adns__query_send(adns_query qu, struct timeval now) {
   
   r= sendto(ads->udpsocket,qu->query_dgram,qu->query_dglen,0,
            (const struct sockaddr*)&servaddr,sizeof(servaddr));
-  if (r<0 && errno == EMSGSIZE) { qu->retries= 0; query_usetcp(qu,now); return; }
-  if (r<0) adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
+  if (r<0 && errno == EMSGSIZE) {
+    qu->retries= 0;
+    query_usetcp(qu,now);
+    return;
+  }
+  if (r<0 && errno != EAGAIN)
+    adns__warn(ads,serv,0,"sendto failed: %s",strerror(errno));
   
   qu->timeout= now;
   timevaladd(&qu->timeout,UDPRETRYMS);