]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2472] Use MySQL for lease manager backend (if present)
authorStephen Morris <stephen@isc.org>
Tue, 13 Nov 2012 12:06:48 +0000 (12:06 +0000)
committerStephen Morris <stephen@isc.org>
Tue, 13 Nov 2012 12:06:48 +0000 (12:06 +0000)
Parameters are hard-coded for the moment.

src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/lib/dhcp/mysql_lease_mgr.cc

index 7370583d684764d2e503c7b9ac90b69c4b672743..555c9ec7547ab37679b76da5b3d1b99ecb5fa781 100644 (file)
@@ -39,9 +39,23 @@ using namespace isc::log;
 using namespace isc::util;
 using namespace std;
 
+namespace {
+// @todo: Replace the next line by extraction from configuration parameters
+// This is the "dbconfig" string for the MySQL database.  It is likely
+// that a long-term solution will be to create the instance of the lease manager
+// somewhere other than the Dhcpv6Srv constructor, to give time to extract
+// the connection string from the configuration database.
+#ifdef HAVE_MYSQL
+const char* DBCONFIG = "type=mysql name=kea user=kea password=kea host=localhost";
+#else
+const char* DBCONFIG = "type=memfile";
+#endif
+};
+
 namespace isc {
 namespace dhcp {
 
+
 ControlledDhcpv6Srv* ControlledDhcpv6Srv::server_ = NULL;
 
 ConstElementPtr
@@ -149,8 +163,8 @@ void ControlledDhcpv6Srv::disconnectSession() {
     IfaceMgr::instance().set_session_socket(IfaceMgr::INVALID_SOCKET, NULL);
 }
 
-ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port /*= DHCP6_SERVER_PORT*/)
-    :Dhcpv6Srv(port), cc_session_(NULL), config_session_(NULL) {
+ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
+    : Dhcpv6Srv(port, DBCONFIG), cc_session_(NULL), config_session_(NULL) {
     server_ = this; // remember this instance for use in callback
 }
 
index f030cd3b8eeac7fbcbaf15bab15bf73768ce702f..78013d77a3b1148f7c04253be97427c1a5c13b3f 100644 (file)
@@ -447,8 +447,9 @@ MySqlLeaseMgr::MySqlLeaseMgr(const LeaseMgr::ParameterMap& parameters)
     // Open the database
     openDatabase();
 
-    // Disable autocommit
-    my_bool result = mysql_autocommit(mysql_, 0);
+    // Enable autocommit.  For maximum speed, the global parameter
+    // innodb_flush_log_at_trx_commit should be set to 2.
+    my_bool result = mysql_autocommit(mysql_, 1);
     if (result != 0) {
         isc_throw(DbOperationError, mysql_error(mysql_));
     }