]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
updates to the new TCP code - there was a bizarre typo which meant that it often...
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 6 Jul 2005 07:10:24 +0000 (07:10 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 6 Jul 2005 07:10:24 +0000 (07:10 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@434 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/lwres.cc
pdns/syncres.cc

index cf77c93f7e0e12de09176c434d9b4e33ee97f11a..7068bcb9ff1f01f012d0e646b894f49b330b8791 100644 (file)
@@ -1,11 +1,10 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002  PowerDNS.COM BV
+    Copyright (C) 2002 - 2005 PowerDNS.COM BV
 
     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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    it under the terms of the GNU General Public License version 2 as 
+    published by the Free Software Foundation
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -103,14 +102,14 @@ int LWRes::asyncresolve(const string &ip, const char *domain, int type, bool doT
     string packet=string(lenP, lenP+2)+string(msgP, msgP+p.len);
 
     if(asendtcp(packet, &s) == 0) {
-      cerr<<"asendtcp: timeout"<<endl;
-      return -1;
+      //      cerr<<"asendtcp: timeout"<<endl;
+      return 0;
     }
     
     packet.clear();
     if(arecvtcp(packet,2, &s)==0) {
-      cerr<<"arecvtcp: timeout"<<endl;
-      return -1;
+      //      cerr<<"arecvtcp: timeout"<<endl;
+      return 0;
     }
 
     memcpy(&len, packet.c_str(), 2);
@@ -119,8 +118,8 @@ int LWRes::asyncresolve(const string &ip, const char *domain, int type, bool doT
     //    cerr<<"Now reading "<<len<<" bytes"<<endl;
 
     if(arecvtcp(packet, len, &s)==0) {
-      cerr<<"arecvtcp: timeout"<<endl;
-      return -1;
+      //      cerr<<"arecvtcp: timeout"<<endl;
+      return 0;
     }
 
     memcpy(d_buf, packet.c_str(), len);
@@ -141,7 +140,7 @@ LWRes::res_t LWRes::result()
     if(p.parse((char *)d_buf, d_len)<0)
       throw LWResException("resolver: unable to parse packet of "+itoa(d_len)+" bytes");
     d_aabit=p.d.aa;
-    d_aabit=p.d.tc;
+    d_tcbit=p.d.tc;
     d_rcode=p.d.rcode;
     return p.getAnswers();
   }
index d7384a1dd33b595dac766bac5cec2ea9e83dc814..7a66b8c0558b80a3aa2e75bbac4579b12994c4d7 100644 (file)
@@ -411,6 +411,17 @@ int SyncRes::doResolveAt(set<string> nameservers, string auth, const string &qna
       }
 
       result=d_lwr.result();
+
+      if(d_lwr.d_tcbit) {
+       if(!doTCP) {
+         doTCP=true;
+         LOG<<prefix<<qname<<": truncated bit set, retrying via TCP"<<endl;
+         goto TryTCP;
+       }
+       LOG<<prefix<<qname<<": truncated bit set, over TCP?"<<endl;
+       return RCode::ServFail;
+      }
+
       if(d_lwr.d_rcode==RCode::ServFail) {
        LOG<<prefix<<qname<<": "<<*tns<<" returned a ServFail, trying sibling NS"<<endl;
        s_throttle.throttle(d_now,remoteIP+"|"+qname+"|"+qtype.getName(),60,3);
@@ -536,15 +547,7 @@ int SyncRes::doResolveAt(set<string> nameservers, string auth, const string &qna
        return doResolve(newtarget, qtype, ret,0,beenthere2);
       }
       if(nsset.empty() && !d_lwr.d_rcode) {
-       if(!negindic && d_lwr.d_tcbit) {
-         if(!doTCP) {
-           doTCP=true;
-           LOG<<prefix<<qname<<": status=noerror, truncated bit set, no negative SOA, retrying via TCP"<<endl;
-           goto TryTCP;
-         }
-         LOG<<prefix<<qname<<": status=noerror, truncated bit set, over TCP?"<<endl;
-         continue;
-       }
+
        LOG<<prefix<<qname<<": status=noerror, other types may exist, but we are done "<<(negindic ? "(have negative SOA)" : "")<<endl;
        return 0;
       }