From: Kees Monshouwer Date: Wed, 9 Oct 2013 22:25:07 +0000 (+0200) Subject: remove xdb backend X-Git-Tag: rec-3.6.0-rc1~419^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5233224cb1e28833d0728325be3747bfdd7eca6;p=pdns remove xdb backend --- diff --git a/build-scripts/tar-gz-build-instruction b/build-scripts/tar-gz-build-instruction index caa421c2f..8cdbb49ee 100755 --- a/build-scripts/tar-gz-build-instruction +++ b/build-scripts/tar-gz-build-instruction @@ -2,6 +2,6 @@ rm -f $(find . -name "*~") && ./bootstrap && ./configure \ --with-pgsql-lib=/opt/postgresql/lib --with-pgsql-includes=/opt/postgresql/include \ ---with-modules="mydns gmysql mongodb lua gpgsql xdb pipe oracle pipe db2 ldap gsqlite3 geo goracle opendbx godbc" \ +--with-modules="mydns gmysql mongodb lua gpgsql pipe oracle pipe db2 ldap gsqlite3 geo goracle opendbx godbc" \ --with-dynmodules="" && make dist \ No newline at end of file diff --git a/configure.ac b/configure.ac index 82d2d3677..b90c840e0 100644 --- a/configure.ac +++ b/configure.ac @@ -771,7 +771,7 @@ pdns/backends/Makefile pdns/backends/bind/Makefile pdns/pdns pdns/precursor \ modules/gmysqlbackend/Makefile modules/db2backend/Makefile \ modules/geobackend/Makefile modules/opendbxbackend/Makefile \ modules/pipebackend/Makefile modules/oraclebackend/Makefile \ -modules/xdbbackend/Makefile modules/godbcbackend/Makefile \ +modules/godbcbackend/Makefile \ modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile \ modules/gsqlite3backend/Makefile \ modules/goraclebackend/Makefile modules/mydnsbackend/Makefile \ diff --git a/modules/Makefile.am b/modules/Makefile.am index f263da099..8b7651cbe 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS=@moduledirs@ -DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend xdbbackend tinydnsbackend remotebackend randombackend +DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend tinydnsbackend remotebackend randombackend diff --git a/modules/xdbbackend/.gitignore b/modules/xdbbackend/.gitignore deleted file mode 100644 index 9ee645401..000000000 --- a/modules/xdbbackend/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile.in -/Makefile diff --git a/modules/xdbbackend/Makefile.am b/modules/xdbbackend/Makefile.am deleted file mode 100644 index 606bd71f1..000000000 --- a/modules/xdbbackend/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -AM_CPPFLAGS=@THREADFLAGS@ -EXTRA_DIST=OBJECTFILES OBJECTLIBS -bin_PROGRAMS=xdb-fill - -lib_LTLIBRARIES = libxdbbackend.la - -libxdbbackend_la_SOURCES=xdbbackend.cc xtdb.cc xtdb.hh xdb.hh xgdbm.hh -libxdbbackend_la_LDFLAGS=-module -avoid-version -ltdb -libxdbbackend_la_CXXFLAGS = $(AM_CXXFLAGS) - -xdb_fill_SOURCES=xdb-fill.cc xtdb.cc xtdb.hh -xdb_fill_LDFLAGS=-ltdb diff --git a/modules/xdbbackend/OBJECTFILES b/modules/xdbbackend/OBJECTFILES deleted file mode 100644 index 1a7dfcf84..000000000 --- a/modules/xdbbackend/OBJECTFILES +++ /dev/null @@ -1 +0,0 @@ -xdbbackend.lo xtdb.lo diff --git a/modules/xdbbackend/OBJECTLIBS b/modules/xdbbackend/OBJECTLIBS deleted file mode 100644 index ad81f2d50..000000000 --- a/modules/xdbbackend/OBJECTLIBS +++ /dev/null @@ -1 +0,0 @@ --ltdb diff --git a/modules/xdbbackend/README b/modules/xdbbackend/README deleted file mode 100644 index aadc9c4ca..000000000 --- a/modules/xdbbackend/README +++ /dev/null @@ -1,6 +0,0 @@ -Currenly not documented and also not recently tested. - -GOOD LUCK! - -But let us know if you need this and have questions. -pdns-dev@mailman.powerdns.com diff --git a/modules/xdbbackend/xdb-fill.cc b/modules/xdbbackend/xdb-fill.cc deleted file mode 100644 index f92c29ee4..000000000 --- a/modules/xdbbackend/xdb-fill.cc +++ /dev/null @@ -1,135 +0,0 @@ -#include "pdns/utility.hh" -#include "xgdbm.hh" -#include "xtdb.hh" -#include "pdns/pdnsexception.hh" -#include "pdns/logger.hh" -#include -#include -#include - -string stringerror() -{ - return strerror(errno); -} - - -string escape(const string &name) -{ - string a; - - for(string::const_iterator i=name.begin();i!=name.end();++i) - if(*i=='|' || *i=='\\'){ - a+='\\'; - a+=*i; - } - else - a+=*i; - return a; -} - -XDBWrapper *db; - -maparecords; - -void doAList(int domain_id, const string &qname, const string &qtype, const string &content, int ttl) -{ - if(qtype!="A") - return; - else arecords[qname]=content; - -} - -void doInsert(int domain_id, const string &qname, const string &qtype, const string &content, int ttl) -{ - static string lastname; - static string writestr; - - - if(!lastname.empty() && lastname!=qname) { - db->append(lastname,writestr); - writestr=""; - } - string rcontent(content); - if(qtype=="NS") { - rcontent+="@"; - map::const_iterator i=arecords.find(content); - if(i!=arecords.end()) - rcontent+=i->second; - } - - ostringstream ostr; - ostr< -using std::string; - -class XDBException -{ -public: - XDBException(const string &ex) : what(ex){} - string what; -}; - -class XDBWrapper -{ -public: - virtual ~XDBWrapper(){} - virtual bool get(const string &key, string &value)=0; - virtual void del(const string &key)=0; - virtual void put(const string &key, const string &value)=0; - virtual void append(const string &key, const string &value) - { - string newKey; - get(key,newKey); - put(key,newKey+value); - } - typedef enum {ReadOnly, ReadWrite} Mode; -}; - -#endif diff --git a/modules/xdbbackend/xdbbackend.cc b/modules/xdbbackend/xdbbackend.cc deleted file mode 100644 index 5a153e162..000000000 --- a/modules/xdbbackend/xdbbackend.cc +++ /dev/null @@ -1,111 +0,0 @@ -#include "pdns/utility.hh" -#include "xtdb.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/dns.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/dnspacket.hh" -#include "pdns/pdnsexception.hh" -#include "pdns/logger.hh" -#include "pdns/arguments.hh" - -/* FIRST PART */ -class XDBBackend : public DNSBackend -{ -public: - XDBBackend(const string &suffix="") - { - setArgPrefix("xdb"+suffix); - try { - d_db=new XTDBWrapper(getArg("filename")); - } - catch(XDBException &e) { - L<get(qdomain, d_answer); // think about lowercasing here - - /* - if(arg().mustDo("query-logging")) { - if(ret) - L< -#include -#include -#include -#include -#include - -#include "pdns/namespaces.hh" - -GDBM_FILE XGDBMWrapper::s_db; -int XGDBMWrapper::s_usecount; - -XGDBMWrapper::XGDBMWrapper(const string &fname, Mode mode) -{ - if(!s_db) { - s_db = gdbm_open(const_cast(fname.c_str()), 2048, - mode==ReadWrite ? GDBM_WRITER|GDBM_WRCREAT|GDBM_FAST : GDBM_READER, - 0666 , 0); - if(!s_db) - throw XDBException("Unable to open database: "+string(strerror(errno))); - } - s_usecount++; -} - -XGDBMWrapper::~XGDBMWrapper() -{ - if(!--s_usecount) { - cerr<<"Closing down"<(key.c_str()),key.size()+1}; - - datum vdatum=gdbm_fetch(s_db,kdatum); - if(!vdatum.dptr) - return false; - value.assign(vdatum.dptr,vdatum.dsize); - free(vdatum.dptr); - return true; -} - -void XGDBMWrapper::put(const string &key, const string &value) -{ - datum kdatum={const_cast(key.c_str()),key.size()+1}; - datum vdatum={const_cast(value.c_str()),value.size()}; - if(gdbm_store(s_db, kdatum, vdatum,GDBM_REPLACE)<0) - throw XDBException("Error storing key: "+string(strerror(errno))); - -} - -void XGDBMWrapper::del(const string &key) -{ -} - -#ifdef TESTDRIVER -main() -{ - try { - XDBWrapper *xdb=new XGDBMWrapper("wuh",XDBWrapper::ReadWrite); - xdb->put("ahu","toffe gast"); - xdb->append("ahu",", echt waar!"); - - string tst; - xdb->get("ahu",tst); - cout<<"Database zegt over ahu: '"<append("ahu"," Toch niet!"); - xdb->get("ahu",tst); - cout<<"Database zegt over ahu: '"< - -class XGDBMWrapper : public XDBWrapper -{ -public: - XGDBMWrapper(const string &filename, Mode mode=ReadOnly); - ~XGDBMWrapper(); - bool get(const string &key, string &value); - void del(const string &key); - void put(const string &key, const string &value); -private: - static GDBM_FILE s_db; - static int s_usecount; -}; -#endif diff --git a/modules/xdbbackend/xtdb.cc b/modules/xdbbackend/xtdb.cc deleted file mode 100644 index 73d2a397e..000000000 --- a/modules/xdbbackend/xtdb.cc +++ /dev/null @@ -1,86 +0,0 @@ -#include "xtdb.hh" -#include "pdns/lock.hh" -#include -#include -#include -#include -#include -#include -#include - - -#include "pdns/namespaces.hh" - -TDB_CONTEXT *XTDBWrapper::s_db; -int XTDBWrapper::s_usecount; -pthread_mutex_t XTDBWrapper::s_lock=PTHREAD_MUTEX_INITIALIZER; - -XTDBWrapper::XTDBWrapper(const string &fname) -{ - Lock l(&s_lock); - if(!s_db) { - s_db = tdb_open(const_cast(fname.c_str()), 5213331, - TDB_NOLOCK, - O_RDWR | O_CREAT , 0600); - if(!s_db) - throw XDBException("Unable to open database: "+string(strerror(errno))); - } - s_usecount++; - -} - -XTDBWrapper::~XTDBWrapper() -{ - if(!--s_usecount) { - tdb_close(s_db); - cerr<<"closed"<(key.c_str()),key.size()+1}; - TDB_DATA vdatum; - - { - //Lock l(&s_lock); - vdatum=tdb_fetch(s_db,kdatum); - } - if(!vdatum.dptr) - return false; - value.assign(vdatum.dptr,vdatum.dsize); - free(vdatum.dptr); - return true; -} - -void XTDBWrapper::put(const string &key, const string &value) -{ - TDB_DATA kdatum={const_cast(key.c_str()),key.size()+1}; - TDB_DATA vdatum={const_cast(value.c_str()),value.size()}; - if(tdb_store(s_db, kdatum, vdatum,TDB_REPLACE)<0) - throw XDBException("Error storing key: "+string(strerror(errno))); - -} - -void XTDBWrapper::del(const string &key) -{ -} - -#ifdef TESTDRIVER -main() -{ - XDBWrapper *xdb=new XTDBWrapper("wuh"); - xdb->put("ahu","toffe gast"); - xdb->append("ahu",", echt waar!"); - - string tst; - xdb->get("ahu",tst); - cout<<"Database zegt over ahu: '"<append("ahu"," Toch niet!"); - xdb->get("ahu",tst); - cout<<"Database zegt over ahu: '"< -#include - -class XTDBWrapper : public XDBWrapper -{ -public: - XTDBWrapper(const string &filename); - ~XTDBWrapper(); - bool get(const string &key, string &value); - void del(const string &key); - void put(const string &key, const string &value); -private: - static TDB_CONTEXT *s_db; - static int s_usecount; - static pthread_mutex_t s_lock; -};