[svn] commit: r1003 - in /trunk/src: bin/auth/auth.spec bin/auth/auth_srv.cc bin/auth/auth_srv.h bin/auth/main.cc lib/config/cpp/ccsession.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Feb 26 17:32:49 UTC 2010
Author: jelte
Date: Fri Feb 26 17:32:49 2010
New Revision: 1003
Log:
simple example to set the database file in auth (which is seen and remembered, but not passed on to the sqlite3datasource yet)
we should look for a decent way to do this without needing a global auth variable (jinmei has some ideas)
Modified:
trunk/src/bin/auth/auth.spec
trunk/src/bin/auth/auth_srv.cc
trunk/src/bin/auth/auth_srv.h
trunk/src/bin/auth/main.cc
trunk/src/lib/config/cpp/ccsession.h
Modified: trunk/src/bin/auth/auth.spec
==============================================================================
--- trunk/src/bin/auth/auth.spec (original)
+++ trunk/src/bin/auth/auth.spec Fri Feb 26 17:32:49 2010
@@ -2,10 +2,10 @@
"module_spec": {
"module_name": "Auth",
"config_data": [
- { "item_name": "default_name",
+ { "item_name": "database_file",
"item_type": "string",
"item_optional": False,
- "item_default": "Hello, world!"
+ "item_default": "b10-auth.db"
},
{ "item_name": "zone_list",
"item_type": "list",
Modified: trunk/src/bin/auth/auth_srv.cc
==============================================================================
--- trunk/src/bin/auth/auth_srv.cc (original)
+++ trunk/src/bin/auth/auth_srv.cc Fri Feb 26 17:32:49 2010
@@ -125,16 +125,26 @@
}
}
+void
+AuthSrv::setDbFile(const std::string& db_file)
+{
+ if (_db_file != db_file) {
+ cout << "Change data source file, call our data source's function to now read " << db_file << endl;
+ _db_file = db_file;
+ }
+}
+
ElementPtr
-AuthSrv::updateConfig(isc::data::ElementPtr config) {
- //if (config->contains("port")) {
- // todo: what to do with port change. restart automatically?
- // ignore atm
- //}
- if (config) {
- std::cout << "[XX] auth: new config " << config << std::endl;
- } else {
- std::cout << "[XX] auth: new config empty" << std::endl;
+AuthSrv::updateConfig(isc::data::ElementPtr new_config) {
+ if (new_config) {
+ // the ModuleCCSession has already checked if we have
+ // the correct ElementPtr type as specified in our .spec file
+ if (new_config->contains("database_file")) {
+ // Since we also get this value if it hasn't changed,
+ // but is non-default, setDbFile here should only really
+ // do anything if it has actually changed
+ setDbFile(new_config->get("database_file")->stringValue());
+ }
}
return isc::config::createAnswer(0);
Modified: trunk/src/bin/auth/auth_srv.h
==============================================================================
--- trunk/src/bin/auth/auth_srv.h (original)
+++ trunk/src/bin/auth/auth_srv.h Fri Feb 26 17:32:49 2010
@@ -27,10 +27,11 @@
int getSocket() { return (sock); }
void processMessage();
void serve(std::string zone_name);
-
+ void setDbFile(const std::string& db_file);
isc::data::ElementPtr updateConfig(isc::data::ElementPtr config);
private:
-
+ std::string _db_file;
+
isc::auth::MetaDataSrc data_src;
int sock;
};
Modified: trunk/src/bin/auth/main.cc
==============================================================================
--- trunk/src/bin/auth/main.cc (original)
+++ trunk/src/bin/auth/main.cc Fri Feb 26 17:32:49 2010
@@ -57,9 +57,10 @@
}
isc::data::ElementPtr
-my_config_handler(isc::data::ElementPtr config)
+my_config_handler(isc::data::ElementPtr new_config)
{
- return auth.updateConfig(config);
+ auth.updateConfig(new_config);
+ return isc::config::createAnswer(0);
}
isc::data::ElementPtr
@@ -106,7 +107,7 @@
isc::config::ModuleCCSession cs = isc::config::ModuleCCSession(specfile,
my_config_handler,
my_command_handler);
-
+
// main server loop
fd_set fds;
int ps = auth.getSocket();
Modified: trunk/src/lib/config/cpp/ccsession.h
==============================================================================
--- trunk/src/lib/config/cpp/ccsession.h (original)
+++ trunk/src/lib/config/cpp/ccsession.h Fri Feb 26 17:32:49 2010
@@ -75,7 +75,7 @@
* 100000 zones, where the whole list is passed every time a single
* thing changes)
*/
- void set_config_handler(isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config)) { config_handler_ = config_handler; };
+ void setConfigHandler(isc::data::ElementPtr(*config_handler)(isc::data::ElementPtr new_config)) { config_handler_ = config_handler; };
/**
* Set a command handler; the function that is passed takes an
More information about the bind10-changes
mailing list