Changeset 234

Show
Ignore:
Timestamp:
02/08/04 11:43:50 (9 years ago)
Author:
ahu
Message:

dynlistener now cleans up after itself
does slightly better error messages
added --version-string
improved pdns_recursor stats logging

Location:
trunk/pdns/pdns
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/common_startup.cc

    r217 r234  
    5858  arg().setCmd("no-config","Don't parse configuration file"); 
    5959   
     60  arg().set("version-string","PowerDNS version in packets - full, anonymous, powerdns or custom")="full";  
    6061  arg().set("control-console","Debugging switch - don't use")="no"; // but I know you will! 
    6162  arg().set("fancy-records","Process URL and MBOXFW records")="no"; 
     
    238239     newuid=Utility::makeUidNumeric(arg()["setuid"]);  
    239240#ifndef WIN32 
     241   gethostbyname("a.root-servers.net"); // this forces all lookup libraries to be loaded 
    240242   if(!arg()["chroot"].empty()) {   
    241243     if(chroot(arg()["chroot"].c_str())<0) { 
  • trunk/pdns/pdns/docs/pdns.sgml

    r228 r234  
    1212    </author> 
    1313     
    14     <PubDate>v2.1 $Date: 2004/02/01 18:20:16 $</PubDate> 
     14    <PubDate>v2.1 $Date: 2004/02/08 10:43:50 $</PubDate> 
    1515     
    1616    <Abstract> 
     
    54405440                Where we send hosts to that need to be url redirected. See <xref linkend="fancy-records">. 
    54415441              </para></listitem></varlistentry> 
     5442          <varlistentry><term>version-string=anonymous|powerdns|full|custom</term> 
     5443            <listitem><para> 
     5444              When queried for its version over DNS (<command>dig chaos txt version.bind @pdns.ip.address</command>), PowerDNS normally 
     5445              resonds truthfully. With this setting you can overrule what will be returned. Set the <command>version-string</command> 
     5446              to 'full' to get the default behaviour, to 'powerdns' to just make it state 'served by PowerDNS - http://www.powerdns.com'.  
     5447              The 'anonymous' setting will return a ServFail, much like Microsoft nameservers do.  You can set this response 
     5448              to a custom value as well. 
     5449              </para></listitem></varlistentry> 
     5450 
    54425451          <varlistentry><term>webserver | --webserver=yes | --webserver=no</term> 
    54435452            <listitem><para> 
  • trunk/pdns/pdns/dynlistener.cc

    r228 r234  
    1717    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1818*/ 
    19 // $Id: dynlistener.cc,v 1.9 2004/02/01 18:20:16 ahu Exp $  
     19// $Id: dynlistener.cc,v 1.10 2004/02/08 10:43:50 ahu Exp $  
    2020/* (C) Copyright 2002 PowerDNS.COM BV */ 
    2121#include <cstring> 
     
    5353extern StatBag S; 
    5454 
     55DynListener::~DynListener() 
     56{ 
     57  if(!d_socketname.empty()) 
     58    unlink(d_socketname.c_str()); 
     59} 
     60 
    5561DynListener::DynListener(const string &pname) 
    5662{ 
    5763  d_restfunc=0; 
    58   string programname=pname; 
     64  string programname(pname); 
    5965 
    6066  if(!programname.empty()) { 
     
    8288     
    8389    socketname+=programname+".controlsocket"; 
    84     unlink(socketname.c_str()); 
     90    int err=unlink(socketname.c_str()); 
     91    if(err < 0 && errno!=ENOENT) { 
     92      L<<Logger::Critical<<"Unable to remove (previous) controlsocket: "<<strerror(errno)<<endl; 
     93      exit(1); 
     94    } 
    8595    memset(&local,0,sizeof(local)); 
    8696    local.sun_family=AF_UNIX; 
     
    91101      exit(1); 
    92102    } 
    93   
     103    d_socketname=socketname; 
    94104    if(!arg()["setgid"].empty()) { 
    95105      if(chown(socketname.c_str(),static_cast<uid_t>(-1),Utility::makeGidNumeric(arg()["setgid"]))<0) 
  • trunk/pdns/pdns/dynlistener.hh

    r87 r234  
    4343public: 
    4444  DynListener(const string &pname=""); 
     45  ~DynListener(); 
    4546  void go(); 
    4647  void theListener(); 
     
    5354  void registerRestFunc(g_funk_t *gf); 
    5455private: 
     56  DynListener(const DynListener &); 
     57  DynListener& operator=(const DynListener &);  
    5558  void sendLine(const string &line); 
    5659  string getLine(); 
     
    7073  pid_t d_ppid; 
    7174   
    72  
     75  string d_socketname; 
    7376  g_funkdb_t d_funcdb; 
    7477  g_funk_t* d_restfunc; 
  • trunk/pdns/pdns/mtasker.cc

    r228 r234  
    284284} 
    285285 
     286//! returns the number of processes running 
     287/** Call this to perhaps limit activities if too many threads are running 
     288    \return number of processes running 
     289 */ 
     290template<class Key, class Val>unsigned int MTasker<Key,Val>::numProcesses() 
     291{ 
     292  return d_threads.size(); 
     293} 
     294 
     295 
    286296//! gives access to the list of Events threads are waiting for 
    287297/** The kernel can call this to get a list of Events threads are waiting for. This is very useful 
  • trunk/pdns/pdns/mtasker.hh

    r141 r234  
    8080  bool schedule(); 
    8181  bool noProcesses(); 
     82  unsigned int numProcesses(); 
    8283  int getTid();  
    8384private: 
  • trunk/pdns/pdns/packethandler.cc

    r228 r234  
    155155 
    156156  if (p->qclass == 3 && p->qtype.getName() == "HINFO") { 
    157     rr.content = "PowerDNS $Id: packethandler.cc,v 1.23 2004/02/01 18:20:16 ahu Exp $"; 
     157    rr.content = "PowerDNS $Id: packethandler.cc,v 1.24 2004/02/08 10:43:50 ahu Exp $"; 
    158158    rr.ttl = 5; 
    159159    rr.qname=target; 
     
    170170{ 
    171171  DNSResourceRecord rr; 
     172   
     173  // modes: anonymous, powerdns only, full, spoofed 
     174  const string mode=arg()["version-string"]; 
    172175  if(p->qtype.getCode()==QType::TXT && target=="version.bind") {// TXT 
    173     rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.23 2004/02/01 18:20:16 ahu Exp $"; 
     176    if(mode.empty() || mode=="full")  
     177      rr.content="Served by POWERDNS "VERSION" $Id: packethandler.cc,v 1.24 2004/02/08 10:43:50 ahu Exp $"; 
     178    else if(mode=="anonymous") { 
     179      r->setRcode(RCode::ServFail); 
     180      return 1; 
     181    } 
     182    else if(mode=="powerdns") 
     183      rr.content="Served by PowerDNS - http://www.powerdns.com"; 
     184    else  
     185      rr.content=mode; 
     186 
    174187    rr.ttl=5; 
    175188    rr.qname=target; 
  • trunk/pdns/pdns/pdns_recursor.cc

    r232 r234  
    338338    L<<Logger::Error<<", "<<(int)(SyncRes::s_throttledqueries*100.0/(SyncRes::s_outqueries+SyncRes::s_throttledqueries))<<"% throttled, " 
    339339     <<SyncRes::s_nodelegated<<" no-delegation drops"<<endl; 
     340    L<<Logger::Error<<"queries running: "<<MT->numProcesses()<<endl; 
    340341     
    341342  }