[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pdns-dev
Subject:    [Pdns-dev] 2.9.15 for Windows patch
From:       Michel Stol <michel () powerdns ! com>
Date:       2004-01-30 12:04:31
Message-ID: opr2k7ttdqjl0271 () localhost
[Download RAW message or body]

Hey Bert,

Here's the patch.

Greetings,

- Michel Stol

["2.9.15-win32.patch" (2.9.15-win32.patch)]

? 2.9.15-win32.patch
? modules/godbcbackend/powerdns.mdb
? pdns/pdnsmsg.hh
? pdns/pdnsmsg.rc
? pdns/pdnsmsg.res
? pdns/powerdns.opt
? pdns/pdns_recursor.plg
? pdns/powerdns.ncb
? pdns/Release
? pdns/Debug
? pdns/pdns.plg
? pdns/MSG00001.bin
? pdns/pdns.conf
? pdns/backends/bind/bindparser.tab.cc
? pdns/backends/bind/bindparser.tab.hh
? pdns/backends/bind/bindlexer.cc
Index: modules/godbcbackend/godbcbackend.cc
===================================================================
RCS file: /var/cvsroot/pdns/modules/godbcbackend/godbcbackend.cc,v
retrieving revision 1.1
diff -u -B -b -r1.1 godbcbackend.cc
--- modules/godbcbackend/godbcbackend.cc	10 Feb 2003 12:08:06 -0000	1.1
+++ modules/godbcbackend/godbcbackend.cc	30 Jan 2004 12:02:00 -0000
@@ -53,14 +53,14 @@
     declare( suffix, "basic-query", "Basic query","select \
content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s'");

     declare( suffix, "id-query", "Basic with ID query","select \
content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s' and \
domain_id=%d");

     declare( suffix, "wildcard-query", "Wildcard query","select \
content,ttl,prio,type,domain_id,name from records where type='%s' and name like \
'%s'");

-    declare( suffix, "wildcard-id-query", "Wildcard with ID query","select \
content,ttl,prio,type,domain_id,name from records where type='%s' and name like '%s' \
and domain_id='%d'");

+    declare( suffix, "wildcard-id-query", "Wildcard with ID query","select \
content,ttl,prio,type,domain_id,name from records where type='%s' and name like '%s' \
and domain_id=%d");  

     declare( suffix, "any-query", "Any query","select \
content,ttl,prio,type,domain_id,name from records where name='%s'");

     declare( suffix, "any-id-query", "Any with ID query","select \
content,ttl,prio,type,domain_id,name from records where name='%s' and domain_id=%d");

     declare( suffix, "wildcard-any-query", "Wildcard ANY query","select \
content,ttl,prio,type,domain_id,name from records where name like '%s'");

-    declare( suffix, "wildcard-any-id-query", "Wildcard ANY with ID query","select \
content,ttl,prio,type,domain_id,name from records where like '%s' and \
domain_id='%d'");

+    declare( suffix, "wildcard-any-id-query", "Wildcard ANY with ID query","select \
content,ttl,prio,type,domain_id,name from records where like '%s' and domain_id=%d"); \


-    declare( suffix, "list-query", "AXFR query", "select \
content,ttl,prio,type,domain_id,name from records where domain_id='%d'");

+    declare( suffix, "list-query", "AXFR query", "select \
                content,ttl,prio,type,domain_id,name from records where \
                domain_id=%d");
     declare( suffix, "master-zone-query", "Data", "select master from domains where \
name='%s' and type='SLAVE'");

 

     declare( suffix, "info-zone-query", "","select \
id,name,master,last_check,notified_serial,type from domains where name='%s'");

Index: modules/godbcbackend/godbcbackend.hh
===================================================================
RCS file: /var/cvsroot/pdns/modules/godbcbackend/godbcbackend.hh,v
retrieving revision 1.1
diff -u -B -b -r1.1 godbcbackend.hh
Index: modules/godbcbackend/sodbc.cc
===================================================================
RCS file: /var/cvsroot/pdns/modules/godbcbackend/sodbc.cc,v
retrieving revision 1.2
diff -u -B -b -r1.2 sodbc.cc
--- modules/godbcbackend/sodbc.cc	30 Nov 2003 10:53:17 -0000	1.2
+++ modules/godbcbackend/sodbc.cc	30 Jan 2004 12:02:00 -0000
@@ -55,6 +55,13 @@
 // Destructor.

 SODBC::~SODBC( void )

 {

+  // Free all allocated column memory.
+  for ( int i = 0; i < m_columnInfo.size(); i++ )
+  {   
+    if ( m_columnInfo[ i ].m_pData )
+      delete m_columnInfo[ i ].m_pData;
+  }
+
   // Disconnect from database and free all used resources.

   SQLFreeHandle( SQL_HANDLE_STMT, m_statement );

 

@@ -62,13 +69,6 @@
 

   SQLFreeHandle( SQL_HANDLE_DBC, m_connection );

   SQLFreeHandle( SQL_HANDLE_ENV, m_environment );

-

-  // Free all allocated column memory.

-  for ( int i = 0; i < m_columnInfo.size(); i++ )

-  {

-    if ( m_columnInfo[ i ].m_pData )

-      delete m_columnInfo[ i ].m_pData;

-  }

 }

 

 

@@ -277,6 +277,8 @@
       delete m_columnInfo[ i ].m_pData;

   }

 

+  m_columnInfo.clear();
+
   SQLFreeStmt( m_statement, SQL_CLOSE );

 

   return false;

Index: pdns/arguments.cc
===================================================================
RCS file: /var/cvsroot/pdns/pdns/arguments.cc,v
retrieving revision 1.6
diff -u -B -b -r1.6 arguments.cc
--- pdns/arguments.cc	16 Jan 2004 22:18:12 -0000	1.6
+++ pdns/arguments.cc	30 Jan 2004 12:02:00 -0000
@@ -17,7 +17,9 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-
+#if _MSC_VER > 1000
+# pragma warning ( disable: 4786 )
+#endif // _MSC_VER > 1000
 
 #include "arguments.hh"
 
Index: pdns/pdns_recursor.cc
===================================================================
RCS file: /var/cvsroot/pdns/pdns/pdns_recursor.cc,v
retrieving revision 1.20
diff -u -B -b -r1.20 pdns_recursor.cc
--- pdns/pdns_recursor.cc	16 Jan 2004 22:18:12 -0000	1.20
+++ pdns/pdns_recursor.cc	30 Jan 2004 12:02:00 -0000
@@ -120,12 +120,14 @@
 
 static void writePid(void)
 {
+#ifndef WIN32
   string fname=arg()["socket-dir"]+"/"+s_programname+".pid";
   ofstream of(fname.c_str());
   if(of)
     of<<getpid()<<endl;
   else
     L<<Logger::Error<<"Requested to write pid for "<<getpid()<<" to "<<fname<<" \
failed: "<<strerror(errno)<<endl; +#endif // WIN32
 }
 
 void primeHints(void)
@@ -192,7 +194,7 @@
       char buf[2];
       buf[0]=R->len/256;
       buf[1]=R->len%256;
-      if(write(R->getSocket(),buf,2)!=2 || \
write(R->getSocket(),buffer,R->len)!=R->len) +      \
if(send(R->getSocket(),buf,2,0)!=2 || send(R->getSocket(),buffer,R->len,0)!=R->len)  \
L<<Logger::Error<<"Oops, partial answer sent to "<<P.getRemote()<<" - probably would \
have trouble receiving our answer anyhow (size="<<R->len<<")"<<endl;  }
 
Index: pdns/pdns_recursor.dsp
===================================================================
RCS file: /var/cvsroot/pdns/pdns/pdns_recursor.dsp,v
retrieving revision 1.1
diff -u -B -b -r1.1 pdns_recursor.dsp
--- pdns/pdns_recursor.dsp	4 Feb 2003 16:33:47 -0000	1.1
+++ pdns/pdns_recursor.dsp	30 Jan 2004 12:02:00 -0000
@@ -107,11 +107,15 @@
 # End Source File

 # Begin Source File

 

-SOURCE=.\pdns_recursor.cc

+SOURCE=.\qtype.cc
 # End Source File

 # Begin Source File

 

-SOURCE=.\qtype.cc

+SOURCE=.\recursor_cache.cc
+# End Source File
+# Begin Source File
+
+SOURCE=.\recursorservice.cc
 # End Source File

 # Begin Source File

 

@@ -131,6 +135,10 @@
 # End Source File

 # Begin Source File

 

+SOURCE=.\win32_pdns_recursor.cc
+# End Source File
+# Begin Source File
+
 SOURCE=.\win32_utility.cc

 # End Source File

 # End Group

@@ -203,6 +211,14 @@
 # End Source File

 # Begin Source File

 

+SOURCE=.\recursor_cache.hh
+# End Source File
+# Begin Source File
+
+SOURCE=.\recursorservice.hh
+# End Source File
+# Begin Source File
+
 SOURCE=.\resolver.hh

 # End Source File

 # Begin Source File

Index: pdns/recursor_cache.cc
===================================================================
RCS file: /var/cvsroot/pdns/pdns/recursor_cache.cc,v
retrieving revision 1.1
diff -u -B -b -r1.1 recursor_cache.cc
--- pdns/recursor_cache.cc	26 Jan 2004 19:03:55 -0000	1.1
+++ pdns/recursor_cache.cc	30 Jan 2004 12:02:00 -0000
@@ -1,3 +1,8 @@
+
+#if _MSC_VER > 1000
+#pragma warning ( disable: 4786 )
+#endif // _MSC_VER
+
 #include "recursor_cache.hh"
 #include "misc.hh"
 #include <iostream>
Index: pdns/utility.hh
===================================================================
RCS file: /var/cvsroot/pdns/pdns/utility.hh,v
retrieving revision 1.7
diff -u -B -b -r1.7 utility.hh
--- pdns/utility.hh	30 Nov 2003 10:53:17 -0000	1.7
+++ pdns/utility.hh	30 Jan 2004 12:02:01 -0000
@@ -64,7 +64,7 @@
 
 # define EINPROGRESS  WSAEWOULDBLOCK
 
-# define VERSION "2.9.13-WIN32"
+# define VERSION "2.9.15-WIN32"
 
 # define snprintf _snprintf
 
Index: pdns/win32_pdns_recursor.cc
===================================================================
RCS file: /var/cvsroot/pdns/pdns/win32_pdns_recursor.cc,v
retrieving revision 1.1
diff -u -B -b -r1.1 win32_pdns_recursor.cc
--- pdns/win32_pdns_recursor.cc	30 Nov 2003 11:18:49 -0000	1.1
+++ pdns/win32_pdns_recursor.cc	30 Jan 2004 12:02:01 -0000
@@ -22,6 +22,9 @@
 #include <errno.h>
 #include <map>
 #include <set>

+#ifndef WIN32
+#include <netdb.h>
+#endif // WIN32
 #include <stdio.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -34,8 +37,11 @@
 #include "syncres.hh"
 #include <fcntl.h>
 #include <fstream>
+#include "recursor_cache.hh"
 #include "recursorservice.hh"

 
+MemRecursorCache RC;
+
 string s_programname="pdns_recursor";
 
 #ifndef WIN32
@@ -110,67 +116,21 @@
   return 1;
 }
 
-typedef map<string,set<DNSResourceRecord> > cache_t;
-static cache_t cache;
-int cacheHits, cacheMisses;
-int getCache(const string &qname, const QType& qt, set<DNSResourceRecord>* res)
-{
-  cache_t::const_iterator j=cache.find(toLower(qname)+"|"+qt.getName());
-  if(j!=cache.end() && j->first==toLower(qname)+"|"+qt.getName() && \
                j->second.begin()->ttl>(unsigned int)time(0)) {
-    if(res)
-      *res=j->second;
 
-    return (unsigned int)j->second.begin()->ttl-time(0);
-  }
 
-  return -1;
-}
 
-void replaceCache(const string &qname, const QType& qt,  const \
set<DNSResourceRecord>& content) +static void writePid(void)
 {
-
-  // bogus code to generate root with very low ttl
-  /*  
-  if((0 && qname.empty()) || qname.rfind(".root-servers.net")==1) {
-    cout<<"qname: '"<<qname<<"'"<<endl;
-    set<DNSResourceRecord> changed;
-    for(set<DNSResourceRecord>::const_iterator \
                i=content.begin();i!=content.end();++i) {
-      DNSResourceRecord j=*i;
-      j.ttl=time(0)+20;
-      changed.insert(j);
-    }
-    cache[qname+"|"+qt.getName()]=changed;
-  }
-  else
-  */
-    cache[toLower(qname)+"|"+qt.getName()]=content;
-}
-
-void doPrune(void)
-{
-  unsigned int names=0, records=0;
-
-  for(cache_t::iterator j=cache.begin();j!=cache.end();){
-    for(set<DNSResourceRecord>::iterator k=j->second.begin();k!=j->second.end();) 
-      if((unsigned int)k->ttl < (unsigned int)time(0)) {
-	j->second.erase(k++);
-	records++;
-      }
+#ifndef WIN32
+  string fname=arg()["socket-dir"]+"/"+s_programname+".pid";
+  ofstream of(fname.c_str());
+  if(of)
+    of<<getpid()<<endl;
       else
-	++k;
-
-    if(j->second.empty()) { // everything is gone
-      cache.erase(j++);
-      names++;
-
-    }
-    else {
-      ++j;
-    }
-  }
+    L<<Logger::Error<<"Requested to write pid for "<<getpid()<<" to "<<fname<<" \
failed: "<<strerror(errno)<<endl; +#endif // WIN32
 }
 
-
 void primeHints(void)
 {
   // prime root cache
@@ -191,11 +151,11 @@
     arr.content=ips[c-'a'];
     set<DNSResourceRecord>aset;
     aset.insert(arr);
-    replaceCache(string(templ),QType(QType::A),aset);
+    RC.replace(string(templ),QType(QType::A),aset);
 
     nsset.insert(nsrr);
   }
-  replaceCache("",QType(QType::NS),nsset);
+  RC.replace("",QType(QType::NS),nsset);
 }
 
 void startDoResolve(void *p)
@@ -245,7 +205,7 @@
 	sr.d_throttledqueries<<" throttled, rcode="<<res<<endl;
     }
     
-    sr.d_outqueries ? cacheMisses++ : cacheHits++;
+    sr.d_outqueries ? RC.cacheMisses++ : RC.cacheHits++; 
 
     delete R;
   }
@@ -344,6 +304,23 @@
   L<<Logger::Error<<"Incoming query source port: "<<arg().asNum("local-port")<<endl;
 }
 
+
+#ifndef WIN32
+void daemonize(void)
+{
+  if(fork())
+    exit(0); // bye bye
+  
+  setsid(); 
+
+  // cleanup open fds, but skip sockets 
+  close(0);
+  close(1);
+  close(2);
+
+}
+#endif
+
 int counter, qcounter;
 bool statsWanted;
 
@@ -356,11 +333,13 @@
 void doStats(void)
 {
   if(qcounter) {
-    L<<Logger::Error<<"stats: "<<qcounter<<" questions, "<<cache.size()<<" cache \
                entries, "<<SyncRes::s_negcache.size()<<" negative entries, "
-     <<(int)((cacheHits*100.0)/(cacheHits+cacheMisses))<<"% cache hits";
+    
+    L<<Logger::Error<<"stats: "<<qcounter<<" questions, "<<RC.size()<<" cache \
entries, "<<SyncRes::s_negcache.size()<<" negative entries, " +     \
                <<(int)((RC.cacheHits*100.0)/(RC.cacheHits+RC.cacheMisses))<<"% cache \
                hits";
     L<<Logger::Error<<", outpacket/query ratio \
                "<<(int)(SyncRes::s_outqueries*100.0/SyncRes::s_queries)<<"%";
     L<<Logger::Error<<", \
"<<(int)(SyncRes::s_throttledqueries*100.0/(SyncRes::s_outqueries+SyncRes::s_throttledqueries))<<"% \
throttled, "  <<SyncRes::s_nodelegated<<" no-delegation drops"<<endl;
+    
   }
   statsWanted=false;
 }
@@ -370,7 +349,7 @@
   static time_t last_stat, last_rootupdate, last_prune;
 
   if(time(0)-last_stat>30) { 
-    doPrune();
+    RC.doPrune();
     last_prune=time(0);
   }
   if(time(0)-last_stat>1800) { 
@@ -521,7 +501,6 @@
 	  tc.fd=newsock;

 	  tc.state=TCPConnection::BYTE0;

 	  tc.remote=addr;

-	  L<<Logger::Error<<"TCP Remote \
"<<sockAddrToString(&tc.remote,sizeof(tc.remote))<<" connected"<<endl;

 	  tcpconnections.push_back(tc);

 	}

       }

@@ -538,8 +517,7 @@
 	      i->state=TCPConnection::GETQUESTION;

 	    }

 	    if(!bytes || bytes < 0) {

-	      L<<Logger::Error<<"TCP Remote \
"<<sockAddrToString(&i->remote,sizeof(i->remote))<<" disconnected"<<endl;

-        Utility::closesocket(i->fd);

+	      closesocket(i->fd);
 	      tcpconnections.erase(i);

 	      break;

 	    }

@@ -553,7 +531,7 @@
 	    }

 	    if(!bytes || bytes < 0) {

 	      L<<Logger::Error<<"TCP Remote \
"<<sockAddrToString(&i->remote,sizeof(i->remote))<<" disconnected after first \
byte"<<endl;

-        Utility::closesocket(i->fd);

+	      closesocket(i->fd);
 	      tcpconnections.erase(i);

 	      break;

 	    }

@@ -563,7 +541,7 @@
 	    int bytes=recv(i->fd,i->data + i->bytesread,i->qlen - i->bytesread,0);

 	    if(!bytes || bytes < 0) {

 	      L<<Logger::Error<<"TCP Remote \
"<<sockAddrToString(&i->remote,sizeof(i->remote))<<" disconnected while reading \
question body"<<endl;

-        Utility::closesocket(i->fd);

+	      closesocket(i->fd);
 	      tcpconnections.erase(i);

 	      break;

 	    }

@@ -573,7 +551,7 @@
 

 	      if(P.parse(i->data,i->qlen)<0) {

 		L<<Logger::Error<<"Unparseable packet from remote client "<<P.getRemote()<<endl;

-    Utility::closesocket(i->fd);

+		closesocket(i->fd);
 		tcpconnections.erase(i);

 		break;

 	      }

@@ -603,9 +581,7 @@
     L<<Logger::Error<<"any other exception in main: "<<endl;

   }

   

-#ifdef WIN32

   WSACleanup();

-#endif // WIN32

 

   return 0;

 }

@@ -624,7 +600,6 @@
   }

 
   try {
-

     Utility::srandom(time(0));
     arg().set("soa-minimum-ttl","Don't change")="0";
     arg().set("soa-serial-offset","Don't change")="0";
@@ -634,9 +609,10 @@
     arg().set("trace","if we should output heaps of logging")="off";
     arg().set("daemon","Operate as a daemon")="yes";
     arg().set("quiet","Suppress logging of questions and answers")="off";
+    arg().set("config-dir","Location of configuration directory \
                (recursor.conf)")="./";
     arg().set("delegation-only","Which domains we only accept delegations from")="";
     arg().setCmd("help","Provide a helpful message");
-    arg().set("config-dir","Location of configuration directory \
(recursor.conf)")="./";

+
     arg().setSwitch( "register-service", "Register the service" )= "no";

     arg().setSwitch( "unregister-service", "Unregister the service" )= "no";

     arg().setSwitch( "ntservice", "Run as service" )= "no";

@@ -712,7 +688,6 @@
       SetConsoleCtrlHandler( consoleHandler, true );

   

     RecursorService::instance()->start( argc, argv, arg().mustDo( "ntservice" )); 

-

   }

   catch(AhuException &ae) {

     L<<Logger::Error<<"Exception: "<<ae.reason<<endl;

@@ -724,5 +699,9 @@
     L<<Logger::Error<<"any other exception in main: "<<endl;

   }

     
+#ifdef WIN32
+  WSACleanup();
+#endif // WIN32
+
   return 0;
 }
Index: pdns/backends/bind/zoneparser2.cc
===================================================================
RCS file: /var/cvsroot/pdns/pdns/backends/bind/zoneparser2.cc,v
retrieving revision 1.21
diff -u -B -b -r1.21 zoneparser2.cc
--- pdns/backends/bind/zoneparser2.cc	17 Jan 2004 13:18:22 -0000	1.21
+++ pdns/backends/bind/zoneparser2.cc	30 Jan 2004 12:02:01 -0000
@@ -19,6 +19,7 @@
 
 #ifdef WIN32
 # pragma warning ( disable: 4786 )
+# define STDIN_FILENO 0
 #endif // WIN32
 
 #include <stdio.h>
Index: pdns/release-scripts/pdns.nsi
===================================================================
RCS file: /var/cvsroot/pdns/pdns/release-scripts/pdns.nsi,v
retrieving revision 1.6
diff -u -B -b -r1.6 pdns.nsi
--- pdns/release-scripts/pdns.nsi	30 Nov 2003 10:53:17 -0000	1.6
+++ pdns/release-scripts/pdns.nsi	30 Jan 2004 12:02:01 -0000
@@ -5,7 +5,7 @@
 ; Defines.

 ;------------------------------------------------------

 

-!define VERSION "2.9.13"

+!define VERSION "2.9.15"
 

 

 ; Output settings.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic