From: bert hubert Date: Fri, 12 Jul 2013 14:23:43 +0000 (+0200) Subject: we still love ahu, but the AhuException had to go. Welcome to the PDNSException. X-Git-Tag: rec-3.6.0-rc1~570 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f81d239d3456a58321e9e411221e38174b28ebf;p=thirdparty%2Fpdns.git we still love ahu, but the AhuException had to go. Welcome to the PDNSException. --- diff --git a/modules/db2backend/DB2Backend.cc b/modules/db2backend/DB2Backend.cc index ead3deaa05..4839f2cfa5 100644 --- a/modules/db2backend/DB2Backend.cc +++ b/modules/db2backend/DB2Backend.cc @@ -249,7 +249,7 @@ DB2Backend::DB2Backend(const string &suffix) } this->Cleanup(); - throw AhuException("DB2Backend Failed to Start"); + throw PDNSException("DB2Backend Failed to Start"); } L << Logger::Warning << kBackendName << " Connection succeeded" << endl; @@ -387,7 +387,7 @@ void DB2Backend::lookup(const QType &qtype, const string &qname, DNSPacket *pkt_ // Rethrow for the nameserver // - throw AhuException("Execute failed"); + throw PDNSException("Execute failed"); } } @@ -430,7 +430,7 @@ bool DB2Backend::list(int inZoneId) catch (DB2Exception& theException) { - throw AhuException("List failed"); + throw PDNSException("List failed"); } return theResult; @@ -494,7 +494,7 @@ bool DB2Backend::get(DNSResourceRecord& outRecord) // Rethrow for the nameserver // - throw AhuException("Fetch failed"); + throw PDNSException("Fetch failed"); } return theResult; @@ -568,7 +568,7 @@ bool DB2Backend::getSOA(const string& inZoneName, SOAData& outSoaData) // Rethrow for the nameserver // - throw AhuException("GetSOA failed"); + throw PDNSException("GetSOA failed"); } return theResult; diff --git a/modules/geobackend/geobackend.cc b/modules/geobackend/geobackend.cc index a339297343..095d88d235 100644 --- a/modules/geobackend/geobackend.cc +++ b/modules/geobackend/geobackend.cc @@ -286,7 +286,7 @@ const string GeoBackend::resolveTarget(const GeoRecord &gr, short isocode) const void GeoBackend::loadZoneName() { zoneName = getArg("zone"); if (zoneName.empty()) - throw AhuException("zone parameter must be set"); + throw PDNSException("zone parameter must be set"); } void GeoBackend::loadTTLValues() { @@ -303,7 +303,7 @@ void GeoBackend::loadSOAValues() { return; if (values.size() != 2) - throw AhuException("Invalid number of soa-values specified in configuration"); + throw PDNSException("Invalid number of soa-values specified in configuration"); soaMasterServer = values[0]; soaHostmaster = values[1]; @@ -317,14 +317,14 @@ void GeoBackend::loadIPLocationMap() { string filename = getArg("ip-map-zonefile"); if (filename.empty()) - throw AhuException("No IP map zonefile specified in configuration"); + throw PDNSException("No IP map zonefile specified in configuration"); // Stat file to see if it has changed since last read struct stat stbuf; if (stat(filename.c_str(), &stbuf) != 0 || !S_ISREG(stbuf.st_mode)) { const string errormsg = "stat() failed, or " + filename + " is no regular file."; if (lastDiscoverTime == 0) // We have no older map, bail out - throw AhuException(errormsg); + throw PDNSException(errormsg); else { // Log, but continue L << Logger::Error << logprefix << errormsg; @@ -337,7 +337,7 @@ void GeoBackend::loadIPLocationMap() { std::ifstream ifs(filename.c_str(), std::ios::in); if (!ifs) - throw AhuException("Unable to open IP map zonefile for read: " + stringerror()); + throw PDNSException("Unable to open IP map zonefile for read: " + stringerror()); L << Logger::Info << logprefix << "Parsing IP map zonefile" << endl; @@ -463,9 +463,9 @@ void GeoBackend::loadDirectorMaps(const vector &newgrs) { mapcount++; } else - throw AhuException("duplicate georecord " + gr->qname + ", skipping"); + throw PDNSException("duplicate georecord " + gr->qname + ", skipping"); } - catch(AhuException &e) { + catch(PDNSException &e) { L << Logger::Error << logprefix << "Error occured while reading director file " << gr->directorfile << ": " << e.reason << endl; delete gr; @@ -488,7 +488,7 @@ void GeoBackend::loadDirectorMap(GeoRecord &gr) { std::ifstream ifs(gr.directorfile.c_str(), std::ios::in); if (!ifs) - throw AhuException("Error opening file."); + throw PDNSException("Error opening file."); string line; while(getline(ifs, line)) { @@ -507,7 +507,7 @@ void GeoBackend::loadDirectorMap(GeoRecord &gr) { gr.qname.resize(gr.qname.size()-1); // Check whether zoneName is a prefix of this FQDN if (gr.qname.rfind(zoneName) == string::npos) - throw AhuException("georecord " + gr.qname + " is out of zone " + zoneName); + throw PDNSException("georecord " + gr.qname + " is out of zone " + zoneName); } continue; } @@ -531,8 +531,8 @@ void GeoBackend::loadDirectorMap(GeoRecord &gr) { // Do some checks on the validness of this director map / georecord if (gr.qname.empty()) - throw AhuException("$RECORD line empty or missing, georecord qname unknown"); + throw PDNSException("$RECORD line empty or missing, georecord qname unknown"); if (gr.dirmap.count(0) == 0) - throw AhuException("No default (0) director map entry"); + throw PDNSException("No default (0) director map entry"); } diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index ce270b712d..f223e86681 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -28,7 +28,7 @@ gMySQLBackend::gMySQLBackend(const string &mode, const string &suffix) : GSQLBa catch(SSqlException &e) { L<doQuery(query); } catch (SSqlException &e) { - throw AhuException("Query failed: "+e.txtReason()); + throw PDNSException("Query failed: "+e.txtReason()); } } @@ -225,7 +225,7 @@ void MyDNSBackend::lookup(const QType &qtype, const string &qname, DNSPacket *p, this->Query(query); if(!d_db->getRow(rrow)) { - throw AhuException("lookup() passed zoneId = "+zoneIdStr+" but no such zone!"); + throw PDNSException("lookup() passed zoneId = "+zoneIdStr+" but no such zone!"); } found = true; diff --git a/modules/opendbxbackend/odbxbackend.cc b/modules/opendbxbackend/odbxbackend.cc index f02df7f73c..e2d8a0df62 100644 --- a/modules/opendbxbackend/odbxbackend.cc +++ b/modules/opendbxbackend/odbxbackend.cc @@ -57,13 +57,13 @@ OdbxBackend::OdbxBackend( const string& suffix ) stringtok( m_hosts[WRITE], getArg( "host-write" ), ", " ); } - if( !connectTo( m_hosts[READ], READ ) ) { throw( AhuException( "Fatal: Connecting to server for reading failed" ) ); } - if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( AhuException( "Fatal: Connecting to server for writing failed" ) ); } + if( !connectTo( m_hosts[READ], READ ) ) { throw( PDNSException( "Fatal: Connecting to server for reading failed" ) ); } + if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( PDNSException( "Fatal: Connecting to server for writing failed" ) ); } } catch( std::exception& e ) { L.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(), Logger::Error ); - throw( AhuException( "Fatal: STL exception" ) ); + throw( PDNSException( "Fatal: STL exception" ) ); } } diff --git a/modules/opendbxbackend/odbxprivate.cc b/modules/opendbxbackend/odbxprivate.cc index 998580c12d..a5f1bec855 100644 --- a/modules/opendbxbackend/odbxprivate.cc +++ b/modules/opendbxbackend/odbxprivate.cc @@ -89,7 +89,7 @@ bool OdbxBackend::getRecord( QueryType type ) if( err < 0 ) { L.log( m_myname + " getRecord: Unable to get next result - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); - throw( AhuException( "Error: odbx_result() failed" ) ); + throw( PDNSException( "Error: odbx_result() failed" ) ); } if( m_result != NULL ) @@ -99,7 +99,7 @@ bool OdbxBackend::getRecord( QueryType type ) if( ( err = odbx_row_fetch( m_result ) ) < 0 ) { L.log( m_myname + " getRecord: Unable to get next row - " + string( odbx_error( m_handle[type], err ) ), Logger::Error ); - throw( AhuException( "Error: odbx_row_fetch() failed" ) ); + throw( PDNSException( "Error: odbx_row_fetch() failed" ) ); } if( err > 0 ) diff --git a/modules/pipebackend/coprocess.cc b/modules/pipebackend/coprocess.cc index 8f9f454f62..c117ec9d79 100644 --- a/modules/pipebackend/coprocess.cc +++ b/modules/pipebackend/coprocess.cc @@ -38,20 +38,20 @@ void CoProcess::launch(const char **argv, int timeout, int infd, int outfd) signal(SIGPIPE, SIG_IGN); if(access(argv[0],X_OK)) // check before fork so we can throw - throw AhuException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror()); + throw PDNSException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror()); if(pipe(d_fd1)<0 || pipe(d_fd2)<0) - throw AhuException("Unable to open pipe for coprocess: "+string(strerror(errno))); + throw PDNSException("Unable to open pipe for coprocess: "+string(strerror(errno))); if((d_pid=fork())<0) - throw AhuException("Unable to fork for coprocess: "+stringerror()); + throw PDNSException("Unable to fork for coprocess: "+stringerror()); else if(d_pid>0) { // parent speaking close(d_fd1[0]); Utility::setCloseOnExec(d_fd1[1]); close(d_fd2[1]); Utility::setCloseOnExec(d_fd2[0]); if(!(d_fp=fdopen(d_fd2[0],"r"))) - throw AhuException("Unable to associate a file pointer with pipe: "+stringerror()); + throw PDNSException("Unable to associate a file pointer with pipe: "+stringerror()); setbuf(d_fp,0); // no buffering please, confuses select } else if(!d_pid) { // child @@ -96,11 +96,11 @@ void CoProcess::checkStatus() int status; int ret=waitpid(d_pid, &status, WNOHANG); if(ret<0) - throw AhuException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno))); + throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno))); else if(ret) { if(WIFEXITED(status)) { int ret=WEXITSTATUS(status); - throw AhuException("Coprocess exited with code "+itoa(ret)); + throw PDNSException("Coprocess exited with code "+itoa(ret)); } if(WIFSIGNALED(status)) { int sig=WTERMSIG(status); @@ -110,7 +110,7 @@ void CoProcess::checkStatus() reason+=". Dumped core"; #endif - throw AhuException(reason); + throw PDNSException(reason); } } } @@ -128,7 +128,7 @@ void CoProcess::send(const string &snd) while(sentsend(line); return; } - catch(AhuException &ae) { + catch(PDNSException &ae) { delete d_cp; d_cp=0; throw; @@ -78,7 +78,7 @@ void CoWrapper::receive(string &line) d_cp->receive(line); return; } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<send(query.str()); } } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<send(query.str()); } - catch(AhuException &ae) { + catch(PDNSException &ae) { L< options) { if (options.count("command") == 0) { L<command = options.find("command")->second; this->options = options; @@ -50,20 +50,20 @@ void PipeConnector::launch() { signal(SIGPIPE, SIG_IGN); if(access(argv[0],X_OK)) // check before fork so we can throw - throw AhuException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror()); + throw PDNSException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror()); if(pipe(d_fd1)<0 || pipe(d_fd2)<0) - throw AhuException("Unable to open pipe for coprocess: "+string(strerror(errno))); + throw PDNSException("Unable to open pipe for coprocess: "+string(strerror(errno))); if((d_pid=fork())<0) - throw AhuException("Unable to fork for coprocess: "+stringerror()); + throw PDNSException("Unable to fork for coprocess: "+stringerror()); else if(d_pid>0) { // parent speaking close(d_fd1[0]); Utility::setCloseOnExec(d_fd1[1]); close(d_fd2[1]); Utility::setCloseOnExec(d_fd2[0]); if(!(d_fp=fdopen(d_fd2[0],"r"))) - throw AhuException("Unable to associate a file pointer with pipe: "+stringerror()); + throw PDNSException("Unable to associate a file pointer with pipe: "+stringerror()); setbuf(d_fp,0); // no buffering please, confuses select } else if(!d_pid) { // child @@ -125,7 +125,7 @@ int PipeConnector::send_message(const rapidjson::Document &input) while(sentsend(value); - } catch (AhuException &ex) { + } catch (PDNSException &ex) { L<recv(value); - } catch (AhuException &ex) { + } catch (PDNSException &ex) { L<connector = new HTTPConnector(options); #else - throw AhuException("Invalid connection string: http connector support not enabled. Recompile with --enable-remotebackend-http"); + throw PDNSException("Invalid connection string: http connector support not enabled. Recompile with --enable-remotebackend-http"); #endif } else if (type == "pipe") { this->connector = new PipeConnector(options); } else { - throw AhuException("Invalid connection string: unknown connector"); + throw PDNSException("Invalid connection string: unknown connector"); } return -1; @@ -162,7 +162,7 @@ void RemoteBackend::lookup(const QType &qtype, const std::string &qdomain, DNSPa rapidjson::Value parameters; if (d_index != -1) - throw AhuException("Attempt to lookup while one running"); + throw PDNSException("Attempt to lookup while one running"); query.SetObject(); JSON_ADD_MEMBER(query, "method", "lookup", query.GetAllocator()) @@ -206,7 +206,7 @@ bool RemoteBackend::list(const std::string &target, int domain_id) { rapidjson::Value parameters; if (d_index != -1) - throw AhuException("Attempt to lookup while one running"); + throw PDNSException("Attempt to lookup while one running"); query.SetObject(); JSON_ADD_MEMBER(query, "method", "list", query.GetAllocator()); @@ -497,7 +497,7 @@ bool RemoteBackend::getDomainInfo(const string &domain, DomainInfo &di) { // make sure we got zone & kind if (!answer["result"].HasMember("zone")) { L<(tmp); } - throw new AhuException("Cannot convert rapidjson value into integer"); + throw new PDNSException("Cannot convert rapidjson value into integer"); } unsigned int RemoteBackend::getUInt(rapidjson::Value &value) { @@ -858,7 +858,7 @@ unsigned int RemoteBackend::getUInt(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new AhuException("Cannot convert rapidjson value into integer"); + throw new PDNSException("Cannot convert rapidjson value into integer"); } int64_t RemoteBackend::getInt64(rapidjson::Value &value) { @@ -870,7 +870,7 @@ int64_t RemoteBackend::getInt64(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new AhuException("Cannot convert rapidjson value into integer"); + throw new PDNSException("Cannot convert rapidjson value into integer"); } std::string RemoteBackend::getString(rapidjson::Value &value) { @@ -879,7 +879,7 @@ std::string RemoteBackend::getString(rapidjson::Value &value) { if (value.IsInt64()) return boost::lexical_cast(value.GetInt64()); if (value.IsInt()) return boost::lexical_cast(value.GetInt()); if (value.IsDouble()) return boost::lexical_cast(value.GetDouble()); - throw new AhuException("Cannot convert rapidjson value into std::string"); + throw new PDNSException("Cannot convert rapidjson value into std::string"); } double RemoteBackend::getDouble(rapidjson::Value &value) { @@ -891,7 +891,7 @@ double RemoteBackend::getDouble(rapidjson::Value &value) { std::string tmp = value.GetString(); return boost::lexical_cast(tmp); } - throw new AhuException("Cannot convert rapidjson value into double"); + throw new PDNSException("Cannot convert rapidjson value into double"); } DNSBackend *RemoteBackend::maker() diff --git a/modules/remotebackend/test-remotebackend-http.cc b/modules/remotebackend/test-remotebackend-http.cc index f91d05ad9f..7fa1be8b47 100644 --- a/modules/remotebackend/test-remotebackend-http.cc +++ b/modules/remotebackend/test-remotebackend-http.cc @@ -52,7 +52,7 @@ struct RemotebackendSetup { ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; - } catch (AhuException &ex) { + } catch (PDNSException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } diff --git a/modules/remotebackend/test-remotebackend-json.cc b/modules/remotebackend/test-remotebackend-json.cc index 1522d52ab7..04b3966b8e 100644 --- a/modules/remotebackend/test-remotebackend-json.cc +++ b/modules/remotebackend/test-remotebackend-json.cc @@ -52,7 +52,7 @@ struct RemotebackendSetup { ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns/endpoint.json,post=1,post_json=1"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; - } catch (AhuException &ex) { + } catch (PDNSException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } diff --git a/modules/remotebackend/test-remotebackend-pipe.cc b/modules/remotebackend/test-remotebackend-pipe.cc index 9a4eb15547..3b0d55ee1f 100644 --- a/modules/remotebackend/test-remotebackend-pipe.cc +++ b/modules/remotebackend/test-remotebackend-pipe.cc @@ -54,7 +54,7 @@ struct RemotebackendSetup { SOARecordContent::report(); NSRecordContent::report(); ARecordContent::report(); - } catch (AhuException &ex) { + } catch (PDNSException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } diff --git a/modules/remotebackend/test-remotebackend-post.cc b/modules/remotebackend/test-remotebackend-post.cc index 754e7a9afd..8326e5a855 100644 --- a/modules/remotebackend/test-remotebackend-post.cc +++ b/modules/remotebackend/test-remotebackend-post.cc @@ -52,7 +52,7 @@ struct RemotebackendSetup { ::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns,post=1"; ::arg().set("remote-dnssec")="yes"; be = BackendMakers().all()[0]; - } catch (AhuException &ex) { + } catch (PDNSException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } diff --git a/modules/remotebackend/test-remotebackend-unix.cc b/modules/remotebackend/test-remotebackend-unix.cc index 823da3be39..b2f9ca09e8 100644 --- a/modules/remotebackend/test-remotebackend-unix.cc +++ b/modules/remotebackend/test-remotebackend-unix.cc @@ -54,7 +54,7 @@ struct RemotebackendSetup { SOARecordContent::report(); NSRecordContent::report(); ARecordContent::report(); - } catch (AhuException &ex) { + } catch (PDNSException &ex) { BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason ); }; } diff --git a/modules/remotebackend/unixconnector.cc b/modules/remotebackend/unixconnector.cc index bd7320d535..e0871a7412 100644 --- a/modules/remotebackend/unixconnector.cc +++ b/modules/remotebackend/unixconnector.cc @@ -10,7 +10,7 @@ UnixsocketConnector::UnixsocketConnector(std::map options) { if (options.count("path") == 0) { L<timeout = 2000; if (options.find("timeout") != options.end()) { diff --git a/modules/tinydnsbackend/cdb.cc b/modules/tinydnsbackend/cdb.cc index 3105c68b83..69b9cc6cb5 100644 --- a/modules/tinydnsbackend/cdb.cc +++ b/modules/tinydnsbackend/cdb.cc @@ -12,14 +12,14 @@ CDB::CDB(const string &cdbfile) if (d_fd < 0) { L<* retDomains) { void TinyDNSBackend::setNotified(uint32_t id, uint32_t serial) { Lock l(&s_domainInfoLock); if (!s_domainInfo.count(d_suffix)) { - throw new AhuException("Can't get list of domains to set the serial."); + throw new PDNSException("Can't get list of domains to set the serial."); } TDI_t *domains = &s_domainInfo[d_suffix]; TDIById_t& domain_index = domains->get(); diff --git a/modules/xdbbackend/xdbbackend.cc b/modules/xdbbackend/xdbbackend.cc index 3f55db2bbe..560b964970 100644 --- a/modules/xdbbackend/xdbbackend.cc +++ b/modules/xdbbackend/xdbbackend.cc @@ -20,7 +20,7 @@ public: } catch(XDBException &e) { L< stage, int id, const string &qnameu, else if(bdr.qname.length() > bb2.d_name.length() && dottedEndsOn(bdr.qname, bb2.d_name)) bdr.qname.resize(bdr.qname.length() - (bb2.d_name.length() + 1)); else - throw AhuException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'"); + throw PDNSException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'"); bdr.qname.swap(bdr.qname); @@ -657,7 +657,7 @@ void Bind2Backend::loadConfig(string* status) try { BP.parse(getArg("config")); } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<id_zone_map[bbd->d_id].d_records->swap(*s_staging_zone_map[bbd->d_id].d_records); } - catch(AhuException &ae) { + catch(PDNSException &ae) { ostringstream msg; msg<<" error at "+nowTime()+" parsing '"<name<<"' from file '"<filename<<"': "<d_status="parsed into memory at "+nowTime(); L<d_name<<"' ("<d_filename<<") reloaded"<d_name<<"' from file '"<d_filename<<"': "<d_status=msg.str(); diff --git a/pdns/backends/bind/binddnssec.cc b/pdns/backends/bind/binddnssec.cc index 6bea89479e..715dc8ca99 100644 --- a/pdns/backends/bind/binddnssec.cc +++ b/pdns/backends/bind/binddnssec.cc @@ -91,7 +91,7 @@ void Bind2Backend::createDNSSECDB(const string& fname) db.doCommand(statement); } catch(SSqlException& se) { - throw AhuException("Error creating database in BIND backend: "+se.txtReason()); + throw PDNSException("Error creating database in BIND backend: "+se.txtReason()); } } @@ -137,7 +137,7 @@ bool Bind2Backend::getDomainMetadata(const string& name, const std::string& kind } } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; } @@ -155,7 +155,7 @@ bool Bind2Backend::setDomainMetadata(const string& name, const std::string& kind d_dnssecdb->doCommand((fmt2 % d_dnssecdb->escape(name) % d_dnssecdb->escape(kind) % d_dnssecdb->escape(meta.begin()->c_str())).str()); } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; @@ -180,7 +180,7 @@ bool Bind2Backend::getDomainKeys(const string& name, unsigned int kind, std::vec } } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; @@ -216,7 +216,7 @@ int Bind2Backend::addDomainKey(const string& name, const KeyData& key) d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % key.flags % key.active % d_dnssecdb->escape(key.content)).str()); } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; @@ -233,7 +233,7 @@ bool Bind2Backend::activateDomainKey(const string& name, unsigned int id) d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % id).str()); } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; @@ -250,7 +250,7 @@ bool Bind2Backend::deactivateDomainKey(const string& name, unsigned int id) d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % id).str()); } catch(SSqlException& se) { - throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); + throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason()); } return true; @@ -266,7 +266,7 @@ bool Bind2Backend::getTSIGKey(const string& name, string* algorithm, string* con d_dnssecdb->doQuery( (fmt % d_dnssecdb->escape(name)).str()); } catch (SSqlException &e) { - throw AhuException("BindBackend unable to retrieve named TSIG key: "+e.txtReason()); + throw PDNSException("BindBackend unable to retrieve named TSIG key: "+e.txtReason()); } SSql::row_t row; diff --git a/pdns/backends/bind/zone2json.cc b/pdns/backends/bind/zone2json.cc index 3de2ec556f..3b8488b581 100644 --- a/pdns/backends/bind/zone2json.cc +++ b/pdns/backends/bind/zone2json.cc @@ -208,7 +208,7 @@ int main(int argc, char **argv) else cerr<doCommand(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); } } @@ -69,7 +69,7 @@ void GSQLBackend::setFresh(uint32_t domain_id) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason()); } } @@ -83,7 +83,7 @@ bool GSQLBackend::isMaster(const string &domain, const string &ip) d_db->doQuery(output, d_result); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); } if(d_result.empty()) @@ -116,7 +116,7 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) d_db->doQuery(output,d_result); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason()); } int numanswers=d_result.size(); @@ -139,7 +139,7 @@ bool GSQLBackend::getDomainInfo(const string &domain, DomainInfo &di) else di.serial=sd.serial; } - catch(AhuException &ae){ + catch(PDNSException &ae){ L< *unfreshDomains) d_db->doQuery(d_InfoOfAllSlaveDomainsQuery, d_result); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason()); } vector allSlaves; @@ -197,7 +197,7 @@ void GSQLBackend::getUpdatedMasters(vector *updatedDomains) d_db->doQuery(d_InfoOfAllMasterDomainsQuery,d_result); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason()); } vector allMasters; @@ -336,7 +336,7 @@ bool GSQLBackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std d_db->doCommand(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } @@ -352,7 +352,7 @@ bool GSQLBackend::nullifyDNSSECOrderNameAndUpdateAuth(uint32_t domain_id, const d_db->doCommand(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } @@ -368,7 +368,7 @@ bool GSQLBackend::nullifyDNSSECOrderNameAndAuth(uint32_t domain_id, const std::s d_db->doCommand(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } @@ -384,7 +384,7 @@ bool GSQLBackend::setDNSSECAuthOnDsRecord(uint32_t domain_id, const std::string& d_db->doCommand(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to set auth on DS record "+qname+" for domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to set auth on DS record "+qname+" for domain_id "+itoa(domain_id)+": "+e.txtReason()); } return true; } @@ -399,7 +399,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const std::string& d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } @@ -411,7 +411,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const std::string& d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to delete empty non-terminal rr "+qname+" from domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to delete empty non-terminal rr "+qname+" from domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } @@ -423,7 +423,7 @@ bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const std::string& d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to insert empty non-terminal rr "+qname+" in domain_id "+itoa(domain_id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to insert empty non-terminal rr "+qname+" in domain_id "+itoa(domain_id)+": "+e.txtReason()); return false; } } @@ -453,7 +453,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { after=row[0]; @@ -465,7 +465,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { after=row[0]; @@ -480,7 +480,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { before=row[0]; @@ -498,7 +498,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason()); + throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason()); } while(d_db->getRow(row)) { before=row[0]; @@ -523,7 +523,7 @@ int GSQLBackend::addDomainKey(const string& name, const KeyData& key) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to store key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to store key: "+e.txtReason()); } return 1; // XXX FIXME, no idea how to get the id } @@ -539,7 +539,7 @@ bool GSQLBackend::activateDomainKey(const string& name, unsigned int id) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to activate key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to activate key: "+e.txtReason()); } return true; } @@ -555,7 +555,7 @@ bool GSQLBackend::deactivateDomainKey(const string& name, unsigned int id) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to deactivate key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to deactivate key: "+e.txtReason()); } return true; } @@ -571,7 +571,7 @@ bool GSQLBackend::removeDomainKey(const string& name, unsigned int id) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to remove key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to remove key: "+e.txtReason()); } return true; } @@ -588,7 +588,7 @@ bool GSQLBackend::getTSIGKey(const string& name, string* algorithm, string* cont d_db->doQuery(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason()); } SSql::row_t row; @@ -613,7 +613,7 @@ bool GSQLBackend::getDomainKeys(const string& name, unsigned int kind, std::vect d_db->doQuery(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to list keys: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to list keys: "+e.txtReason()); } SSql::row_t row; @@ -655,7 +655,7 @@ bool GSQLBackend::getDomainMetadata(const string& name, const std::string& kind, d_db->doQuery(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to list metadata: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason()); } SSql::row_t row; @@ -684,7 +684,7 @@ bool GSQLBackend::setDomainMetadata(const string& name, const std::string& kind, d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to store metadata key: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to store metadata key: "+e.txtReason()); } return true; @@ -744,7 +744,7 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_ d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException(e.txtReason()); + throw PDNSException(e.txtReason()); } d_qname=qname; @@ -762,7 +762,7 @@ bool GSQLBackend::list(const string &target, int domain_id ) d_db->doQuery(output); } catch(SSqlException &e) { - throw AhuException("GSQLBackend list query: "+e.txtReason()); + throw PDNSException("GSQLBackend list query: "+e.txtReason()); } d_qname=""; @@ -782,7 +782,7 @@ bool GSQLBackend::superMasterBackend(const string &ip, const string &domain, con d_db->doQuery(output, d_result); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to search for a domain: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to search for a domain: "+e.txtReason()); } if(!d_result.empty()) { @@ -804,7 +804,7 @@ bool GSQLBackend::createSlaveDomain(const string &ip, const string &domain, cons d_db->doCommand(output); } catch(SSqlException &e) { - throw AhuException("Database error trying to insert new slave '"+domain+"': "+ e.txtReason()); + throw PDNSException("Database error trying to insert new slave '"+domain+"': "+ e.txtReason()); } return true; } @@ -817,7 +817,7 @@ void GSQLBackend::getAllDomains(vector *domains) d_db->doQuery(d_getAllDomainsQuery.c_str()); } catch (SSqlException &e) { - throw AhuException("Database error trying to retrieve all domains:" + e.txtReason()); + throw PDNSException("Database error trying to retrieve all domains:" + e.txtReason()); } SSql::row_t row; @@ -909,7 +909,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername) d_db->doCommand(output.c_str()); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to feed record: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to feed record: "+e.txtReason()); } return true; // XXX FIXME this API should not return 'true' I think -ahu } @@ -924,7 +924,7 @@ bool GSQLBackend::feedEnts(int domain_id, set& nonterm) d_db->doCommand(output.c_str()); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); } } return true; @@ -948,7 +948,7 @@ bool GSQLBackend::feedEnts3(int domain_id, const string &domain, set &no d_db->doCommand(output.c_str()); } catch (SSqlException &e) { - throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); + throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason()); } } return true; @@ -965,7 +965,7 @@ bool GSQLBackend::startTransaction(const string &domain, int domain_id) d_db->doCommand(output); } catch (SSqlException &e) { - throw AhuException("Database failed to start transaction: "+e.txtReason()); + throw PDNSException("Database failed to start transaction: "+e.txtReason()); } return true; @@ -977,7 +977,7 @@ bool GSQLBackend::commitTransaction() d_db->doCommand("commit"); } catch (SSqlException &e) { - throw AhuException("Database failed to commit transaction: "+e.txtReason()); + throw PDNSException("Database failed to commit transaction: "+e.txtReason()); } return true; } @@ -988,7 +988,7 @@ bool GSQLBackend::abortTransaction() d_db->doCommand("rollback"); } catch(SSqlException &e) { - throw AhuException("Database failed to abort transaction: "+string(e.txtReason())); + throw PDNSException("Database failed to abort transaction: "+string(e.txtReason())); } return true; } diff --git a/pdns/communicator.cc b/pdns/communicator.cc index 4f2038e79b..fbe9f167d0 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -97,7 +97,7 @@ void CommunicatorClass::mainloop(void) } } } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<void *Distributorquestion(q); // a can be NULL! delete q; } - catch(const AhuException &e) { + catch(const PDNSException &e) { L<void *Distributorint Distributorquestion(q); // a can be NULL! } - catch(const AhuException &e) { + catch(const PDNSException &e) { L<BackendMakerClass::all(bool metadataOnly) { vectorret; if(d_instances.empty()) - throw AhuException("No database backends configured for launch, unable to function"); + throw PDNSException("No database backends configured for launch, unable to function"); try { for(vector >::const_iterator i=d_instances.begin();i!=d_instances.end();++i) { @@ -178,12 +178,12 @@ vectorBackendMakerClass::all(bool metadataOnly) else made = d_repository[i->first]->make(i->second); if(!made) - throw AhuException("Unable to launch backend '"+i->first+"'"); + throw PDNSException("Unable to launch backend '"+i->first+"'"); ret.push_back(made); } } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<::const_iterator i=ret.begin();i!=ret.end();++i) diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index 2dae53cba0..7bc4185dae 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -70,7 +70,7 @@ class DNSPacket; issues should lead to DBExceptions. More serious errors, which may indicate that the database connection is hosed, or a configuration error occurred, should - lead to the throwing of an AhuException. This exception will fall straight through the UeberBackend and the PacketHandler + lead to the throwing of an PDNSException. This exception will fall straight through the UeberBackend and the PacketHandler and be caught by the Distributor, which will delete your DNSBackend instance and spawn a new one. */ class DNSBackend @@ -310,10 +310,10 @@ private: extern BackendMakerClass &BackendMakers(); //! Exception that can be thrown by a DNSBackend to indicate a failure -class DBException : public AhuException +class DBException : public PDNSException { public: - DBException(const string &reason) : AhuException(reason){} + DBException(const string &reason) : PDNSException(reason){} }; diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index ce02ab4e11..5509637fec 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -551,7 +551,7 @@ catch(std::exception &e) { errlog("Fatal: %s", e.what()); } -catch(AhuException &ae) +catch(PDNSException &ae) { errlog("Fatal: %s", ae.reason); } diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 09f49f68e8..afa114ffaa 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -38,7 +38,7 @@ DNSProxy::DNSProxy(const string &remote) ComboAddress remaddr(remote, 53); if((d_sock=socket(remaddr.sin4.sin_family, SOCK_DGRAM,0))<0) - throw AhuException(string("socket: ")+strerror(errno)); + throw PDNSException(string("socket: ")+strerror(errno)); ComboAddress local; if(remaddr.sin4.sin_family==AF_INET) @@ -56,11 +56,11 @@ DNSProxy::DNSProxy(const string &remote) if(n==10) { Utility::closesocket(d_sock); d_sock=-1; - throw AhuException(string("binding dnsproxy socket: ")+strerror(errno)); + throw PDNSException(string("binding dnsproxy socket: ")+strerror(errno)); } if(connect(d_sock, (sockaddr *)&remaddr, remaddr.getSocklen())<0) - throw AhuException("Unable to UDP connect to remote nameserver "+remaddr.toStringWithPort()+": "+stringerror()); + throw PDNSException("Unable to UDP connect to remote nameserver "+remaddr.toStringWithPort()+": "+stringerror()); d_xor=Utility::random()&0xffff; L<&parts, Utility::pid_t ppid) P.getBackend()->rediscover(&status); return status; } - catch(AhuException &ae) { + catch(PDNSException &ae) { return ae.reason; } diff --git a/pdns/dynlistener.cc b/pdns/dynlistener.cc index 32e526da1c..597eadd508 100644 --- a/pdns/dynlistener.cc +++ b/pdns/dynlistener.cc @@ -72,7 +72,7 @@ void DynListener::createSocketAndBind(int family, struct sockaddr*local, size_t int tmp=1; if(setsockopt(d_s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) - throw AhuException(string("Setsockopt failed on control socket: ")+strerror(errno)); + throw PDNSException(string("Setsockopt failed on control socket: ")+strerror(errno)); if(bind(d_s, local, len) < 0) { if (family == AF_UNIX) @@ -262,14 +262,14 @@ string DynListener::getLine() else { if(isatty(0)) if(write(1, "% ", 2) !=2) - throw AhuException("Writing to console: "+stringerror()); + throw PDNSException("Writing to console: "+stringerror()); if((len=read(0, &mesg[0], mesg.size())) < 0) - throw AhuException("Reading from the control pipe: "+stringerror()); + throw PDNSException("Reading from the control pipe: "+stringerror()); else if(len==0) - throw AhuException("Guardian exited - going down as well"); + throw PDNSException("Guardian exited - going down as well"); if(len == (int)mesg.size()) { - throw AhuException("Line on control console was too long"); + throw PDNSException("Line on control console was too long"); } mesg[len]=0; } @@ -346,7 +346,7 @@ void DynListener::theListener() sendLine((*(s_funcdb[parts[0]].func))(parts,d_ppid)); } } - catch(AhuException &AE) + catch(PDNSException &AE) { L<parts; stringtok(parts,descr,":"); if(parts.empty()) - throw AhuException("Unable to parse '"+descr+"' as a service"); + throw PDNSException("Unable to parse '"+descr+"' as a service"); st.host=parts[0]; if(parts.size()>1) st.port=atoi(parts[1].c_str()); @@ -292,7 +292,7 @@ static void parseService6(const string &descr, ServiceTuple &st) { string::size_type pos=descr.find(']'); if(pos == string::npos) - throw AhuException("Unable to parse '"+descr+"' as an IPv6 service"); + throw PDNSException("Unable to parse '"+descr+"' as an IPv6 service"); st.host=descr.substr(1, pos-1); if(pos + 2 < descr.length()) @@ -303,7 +303,7 @@ static void parseService6(const string &descr, ServiceTuple &st) void parseService(const string &descr, ServiceTuple &st) { if(descr.empty()) - throw AhuException("Unable to parse '"+descr+"' as a service"); + throw PDNSException("Unable to parse '"+descr+"' as a service"); vector parts; stringtok(parts, descr, ":"); @@ -804,5 +804,5 @@ bool stringfgets(FILE* fp, std::string& line) Regex::Regex(const string &expr) { if(regcomp(&d_preg, expr.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED)) - throw AhuException("Regular expression did not compile"); + throw PDNSException("Regular expression did not compile"); } diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index da25beca0d..a1bf64edf0 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -47,7 +47,7 @@ extern StatBag S; \section overview High level overview The Distributor contains a configurable number of PacketHandler instances, each in its own thread, for connection pooling. - PacketHandler instances are recycled of they let escape an AhuException. + PacketHandler instances are recycled of they let escape an PDNSException. The PacketHandler implements the RFC1034 algorithm and converts question packets into DNSBackend queries. @@ -91,7 +91,7 @@ void UDPNameserver::bindIPv4() stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) - throw AhuException("No local address specified"); + throw PDNSException("No local address specified"); int s; for(vector::const_iterator i=locals.begin();i!=locals.end();++i) { @@ -101,12 +101,12 @@ void UDPNameserver::bindIPv4() s=socket(AF_INET,SOCK_DGRAM,0); if(s<0) - throw AhuException("Unable to acquire a UDP socket: "+string(strerror(errno))); + throw PDNSException("Unable to acquire a UDP socket: "+string(strerror(errno))); Utility::setCloseOnExec(s); if(!Utility::setNonBlocking(s)) - throw AhuException("Unable to set UDP socket to non-blocking: "+stringerror()); + throw PDNSException("Unable to set UDP socket to non-blocking: "+stringerror()); memset(&locala,0,sizeof(locala)); locala.sin4.sin_family=AF_INET; @@ -117,12 +117,12 @@ void UDPNameserver::bindIPv4() } locala=ComboAddress(localname, ::arg().asNum("local-port")); if(locala.sin4.sin_family != AF_INET) - throw AhuException("Attempting to bind IPv4 socket to IPv6 address"); + throw PDNSException("Attempting to bind IPv4 socket to IPv6 address"); g_localaddresses.push_back(locala); if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) { L<createSlaveDomain(p->getRemote(),p->qdomain,account); } - catch(AhuException& ae) { + catch(PDNSException& ae) { L<qdomain<<" for potential supermaster "<getRemote()<<": "<qdomain); } - catch(AhuException &e) { + catch(PDNSException &e) { L<removeReadFD(*i); @@ -330,7 +330,7 @@ public: return ret; if(ret<0) - throw AhuException("Making a socket for resolver (family = "+lexical_cast(family)+"): "+stringerror()); + throw PDNSException("Making a socket for resolver (family = "+lexical_cast(family)+"): "+stringerror()); Utility::setCloseOnExec(ret); @@ -349,7 +349,7 @@ public: break; } if(!tries) - throw AhuException("Resolver binding to local query client socket: "+stringerror()); + throw PDNSException("Resolver binding to local query client socket: "+stringerror()); Utility::setNonBlocking(ret); return ret; @@ -674,7 +674,7 @@ void startDoResolve(void *p) delete dc; dc=0; } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<::const_iterator i=locals.begin();i!=locals.end();++i) { ServiceTuple st; @@ -952,14 +952,14 @@ void makeTCPServerSockets() if(!IpToU32(st.host, (uint32_t*)&sin.sin4.sin_addr.s_addr)) { sin.sin6.sin6_family = AF_INET6; if(makeIPv6sockaddr(st.host, &sin.sin6) < 0) - throw AhuException("Unable to resolve local address for TCP server on '"+ st.host +"'"); + throw PDNSException("Unable to resolve local address for TCP server on '"+ st.host +"'"); } fd=socket(sin.sin6.sin6_family, SOCK_STREAM, 0); Utility::setCloseOnExec(fd); if(fd<0) - throw AhuException("Making a TCP server socket for resolver: "+stringerror()); + throw PDNSException("Making a TCP server socket for resolver: "+stringerror()); int tmp=1; if(setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) { @@ -977,7 +977,7 @@ void makeTCPServerSockets() sin.sin4.sin_port = htons(st.port); int socklen=sin.sin4.sin_family==AF_INET ? sizeof(sin.sin4) : sizeof(sin.sin6); if (::bind(fd, (struct sockaddr *)&sin, socklen )<0) - throw AhuException("Binding TCP server socket for "+ st.host +": "+stringerror()); + throw PDNSException("Binding TCP server socket for "+ st.host +": "+stringerror()); Utility::setNonBlocking(fd); setSocketSendBuffer(fd, 65000); @@ -1000,7 +1000,7 @@ void makeUDPServerSockets() stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) - throw AhuException("No local address specified"); + throw PDNSException("No local address specified"); if(::arg()["local-address"]=="0.0.0.0") { L<(st.port) +" for "+ st.host+": "+stringerror()); + throw PDNSException("Resolver binding to server socket on port "+ lexical_cast(st.port) +" for "+ st.host+": "+stringerror()); Utility::setNonBlocking(fd); @@ -1177,7 +1177,7 @@ try L<c_str()); if(::sendto(d_fd, msg.c_str(), msg.length(), 0, (struct sockaddr*) &remoteaddr, sizeof(remoteaddr) ) < 0) - throw AhuException("Unable to send message over control channel '"+*remote+"': "+string(strerror(errno))); + throw PDNSException("Unable to send message over control channel '"+*remote+"': "+string(strerror(errno))); } else if(::send(d_fd, msg.c_str(), msg.length(), 0) < 0) - throw AhuException("Unable to send message over control channel: "+string(strerror(errno))); + throw PDNSException("Unable to send message over control channel: "+string(strerror(errno))); } string RecursorControlChannel::recv(std::string* remote, unsigned int timeout) @@ -132,7 +132,7 @@ string RecursorControlChannel::recv(std::string* remote, unsigned int timeout) socklen_t addrlen=sizeof(remoteaddr); if((waitForData(d_fd, timeout, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0) - throw AhuException("Unable to receive message over control channel: "+string(strerror(errno))); + throw PDNSException("Unable to receive message over control channel: "+string(strerror(errno))); if(remote) *remote=remoteaddr.sun_path; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 8afa9356e7..2fd181d05d 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -660,9 +660,9 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP L<&parts, pid_t ppid) try { writen2(g_fd1[1],line.c_str(),line.size()+1); } - catch(AhuException &ae) { + catch(PDNSException &ae) { return "Error communicating with instance: "+ae.reason; } char mesg[512]; @@ -587,7 +587,7 @@ int main(int argc, char **argv) try { mainthread(); } - catch(AhuException &AE) { + catch(PDNSException &AE) { if(!::arg().mustDo("daemon")) cerr<<"Exiting because: "< fp=shared_ptr(rfp, fclose); @@ -364,7 +364,7 @@ SyncRes::domainmap_t* parseAuthAndForwards() ad.d_rdForward = false; if(domain.empty()) { delete newMap; - throw AhuException("Error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); + throw PDNSException("Error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); } try { @@ -372,7 +372,7 @@ SyncRes::domainmap_t* parseAuthAndForwards() } catch(...) { delete newMap; - throw AhuException("Conversion error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); + throw PDNSException("Conversion error parsing line "+lexical_cast(linenum)+" of " +::arg()["forward-zones-file"]); } (*newMap)[toCanonic("", domain)]=ad; diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 13043c1ff8..7ceb9288d9 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -68,7 +68,7 @@ int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) if(!tries) { Utility::closesocket(sock); - throw AhuException("Resolver binding to local UDP socket on "+ourLocal.toString()+": "+stringerror()); + throw PDNSException("Resolver binding to local UDP socket on "+ourLocal.toString()+": "+stringerror()); } } else { @@ -76,7 +76,7 @@ int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) // cerr<<"letting kernel pick TCP port"<abortTransaction(); } } - catch(AhuException &ae) { - L<abortTransaction(); @@ -430,7 +430,7 @@ struct SlaveSenderReceiver dni.dnssecOk, dni.tsigkeyname, dni.tsigalgname, dni.tsigsecret) ); } - catch(AhuException& e) { + catch(PDNSException& e) { throw runtime_error("While attempting to query freshness of '"+dni.di.zone+"': "+e.reason); } } @@ -556,7 +556,7 @@ void CommunicatorClass::slaveRefresh(PacketHandler *P) catch(std::exception& e) { L< parts; stringtok( parts, ::arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist? @@ -867,7 +867,7 @@ TCPNameserver::TCPNameserver() int s=socket(AF_INET,SOCK_STREAM,0); if(s<0) - throw AhuException("Unable to acquire TCP socket: "+stringerror()); + throw PDNSException("Unable to acquire TCP socket: "+stringerror()); Utility::setCloseOnExec(s); @@ -881,7 +881,7 @@ TCPNameserver::TCPNameserver() if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) { L< SEM_VALUE_MAX) { - throw AhuException("Cannot create semaphore: value too large"); + throw PDNSException("Cannot create semaphore: value too large"); } // Initialize if (pthread_mutex_init(&m_lock, NULL) != 0) { - throw AhuException("Cannot create semaphore: cannot allocate mutex"); + throw PDNSException("Cannot create semaphore: cannot allocate mutex"); } if (pthread_cond_init(&m_gtzero, NULL) != 0) { pthread_mutex_destroy(&m_lock); - throw AhuException("Cannot create semaphore: cannot allocate condition"); + throw PDNSException("Cannot create semaphore: cannot allocate condition"); } m_count = (uint32_t) value; diff --git a/pdns/unix_utility.cc b/pdns/unix_utility.cc index 862e0587d8..987a405529 100644 --- a/pdns/unix_utility.cc +++ b/pdns/unix_utility.cc @@ -44,7 +44,7 @@ int Utility::closesocket( Utility::sock_t socket ) if(ret < 0 && errno == ECONNRESET) // see ticket 192, odd BSD behaviour return 0; if(ret < 0) - throw AhuException("Error closing socket: "+stringerror()); + throw PDNSException("Error closing socket: "+stringerror()); return ret; } diff --git a/pdns/win32_dynlistener.cc b/pdns/win32_dynlistener.cc index 4222f03662..b24030fba7 100644 --- a/pdns/win32_dynlistener.cc +++ b/pdns/win32_dynlistener.cc @@ -101,10 +101,10 @@ string DynListener::getLine() DWORD bytesRead; if ( !ConnectNamedPipe( m_pipeHandle, NULL )) - throw AhuException( "Reading from named pipe failed." ); + throw PDNSException( "Reading from named pipe failed." ); if ( !ReadFile( m_pipeHandle, mesg, sizeof( mesg ), &bytesRead, NULL )) - throw AhuException( "Reading from named pipe failed." ); + throw PDNSException( "Reading from named pipe failed." ); return mesg; } @@ -160,7 +160,7 @@ void DynListener::theListener() sendLine((*d_funcdb[parts[0]])(parts,d_ppid)); } } - catch(AhuException &AE) + catch(PDNSException &AE) { L<start( argc, argv, arg().mustDo( "ntservice" )); } - catch(AhuException &ae) { + catch(PDNSException &ae) { L<