/*
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
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);
// 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);
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();
}
}
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);
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;
}