From: Aki Tuomi Date: Sun, 27 Apr 2014 14:38:34 +0000 (+0300) Subject: Optimize abiVersion usage X-Git-Tag: rec-3.6.0~19^2~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b16334ff41498a59f294fd7dcc224d6e15a7423;p=thirdparty%2Fpdns.git Optimize abiVersion usage --- diff --git a/modules/pipebackend/pipebackend.cc b/modules/pipebackend/pipebackend.cc index 1c8e1d023c..a5f5c493dd 100644 --- a/modules/pipebackend/pipebackend.cc +++ b/modules/pipebackend/pipebackend.cc @@ -32,6 +32,7 @@ CoWrapper::CoWrapper(const string &command, int timeout) d_cp=0; d_command=command; d_timeout=timeout; + d_abiVersion = ::arg().asNum("pipebackend-abi-version"); launch(); // let exceptions fall through - if initial launch fails, we want to die // I think } @@ -52,7 +53,7 @@ void CoWrapper::launch() d_cp = new UnixRemote(d_command, d_timeout); else d_cp = new CoProcess(d_command, d_timeout); - d_cp->send("HELO\t"+lexical_cast(::arg().asNum("pipebackend-abi-version"))); + d_cp->send("HELO\t"+lexical_cast(d_abiVersion)); string banner; d_cp->receive(banner); L<(new CoWrapper(getArg("command"), getArgAsNum("timeout"))); d_regex=getArg("regex").empty() ? 0 : new Regex(getArg("regex")); d_regexstr=getArg("regex"); + d_abiVersion = ::arg().asNum("pipebackend-abi-version"); } catch(const ArgException &A) { L<getRealRemote(); remoteIP = pkt_p->getRemote(); } - int abiVersion = ::arg().asNum("pipebackend-abi-version"); // pipebackend-abi-version = 1 // type qname qclass qtype id remote-ip-address query<<"Q\t"<= 2) + if (d_abiVersion >= 2) query<<"\t"<= 3) + if(d_abiVersion >= 3) query <<"\t"<= 4) + if (d_abiVersion >= 4) query<<"AXFR\t"<send(query.str()); } @@ -195,9 +196,8 @@ bool PipeBackend::get(DNSResourceRecord &r) // The answer format: // DATA qname qclass qtype ttl id content - int abiVersion = ::arg().asNum("pipebackend-abi-version"); unsigned int extraFields = 0; - if(abiVersion == 3) + if(d_abiVersion == 3) extraFields = 2; for(;;) { @@ -225,7 +225,7 @@ bool PipeBackend::get(DNSResourceRecord &r) // now what? } - if(abiVersion == 3) { + if(d_abiVersion == 3) { r.scopeMask = atoi(parts[1].c_str()); r.auth = atoi(parts[2].c_str()); } else { diff --git a/modules/pipebackend/pipebackend.hh b/modules/pipebackend/pipebackend.hh index 07bc3995cc..8131270300 100644 --- a/modules/pipebackend/pipebackend.hh +++ b/modules/pipebackend/pipebackend.hh @@ -29,6 +29,7 @@ private: string d_command; void launch(); int d_timeout; + int d_abiVersion; }; class PipeBackend : public DNSBackend @@ -49,6 +50,7 @@ private: Regex* d_regex; string d_regexstr; bool d_disavow; + int d_abiVersion; };