From: bert hubert Date: Tue, 6 Jan 2015 11:56:38 +0000 (+0100) Subject: scavenge some further malloc calls, plus don't attempt to make socket nonblocking... X-Git-Tag: rec-3.7.0-rc1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a903b39cfe7364c56324038264d3db50b8cece87;p=thirdparty%2Fpdns.git scavenge some further malloc calls, plus don't attempt to make socket nonblocking before we know it is open! Plus some comments on non-observed speedups on reducing system calls by passing CLO_EXEC and NONBLOCK to socket directly --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index fafaf8f352..7349a88410 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -338,7 +338,7 @@ public: // returns -1 for errors which might go away, throws for ones that won't static int makeClientSocket(int family) { - int ret=(int)socket(family, SOCK_DGRAM, 0); + int ret=(int)socket(family, SOCK_DGRAM, 0 ); // turns out that setting CLO_EXEC and NONBLOCK from here is not a performance win on Linux (oddly enough) if(ret < 0 && errno==EMFILE) // this is not a catastrophic error return ret; @@ -512,16 +512,22 @@ void updateResponseStats(int res, const ComboAddress& remote, unsigned int packe ResponseStats g_rs; +static string makeLoginfo(DNSComboWriter* dc) +try +{ + return "("+dc->d_mdp.d_qname+"/"+DNSRecordContent::NumberToType(dc->d_mdp.d_qtype)+" from "+(dc->d_remote.toString())+")"; +} +catch(...) +{ + return "Exception making error message for exception"; +} + void startDoResolve(void *p) { DNSComboWriter* dc=(DNSComboWriter *)p; - string loginfo=""; - try { t_queryring->push_back(make_pair(dc->d_mdp.d_qname, dc->d_mdp.d_qtype)); - loginfo=" (while setting loginfo)"; - loginfo=" ("+dc->d_mdp.d_qname+"/"+DNSRecordContent::NumberToType(dc->d_mdp.d_qtype)+" from "+(dc->d_remote.toString())+")"; uint32_t maxanswersize= dc->d_tcp ? 65535 : min((uint16_t) 512, g_udpTruncationThreshold); EDNSOpts edo; if(getEDNSOpts(dc->d_mdp, &edo) && !dc->d_tcp) { @@ -742,19 +748,19 @@ void startDoResolve(void *p) dc=0; } catch(PDNSException &ae) { - L<d_mdp.d_qname<<", "<d_mdp.d_qname<<", "<getMaxStackUsage(), g_stats.maxMThreadStackUsage); @@ -1040,11 +1046,11 @@ void makeTCPServerSockets() } fd=socket(sin.sin6.sin6_family, SOCK_STREAM, 0); - Utility::setCloseOnExec(fd); - if(fd<0) throw PDNSException("Making a TCP server socket for resolver: "+stringerror()); + Utility::setCloseOnExec(fd); + int tmp=1; if(setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { L<