]> granicus.if.org Git - icinga2/commitdiff
Implement socket_path attribute for the IdoMysqlConnection class
authorGunnar Beutner <gunnar@beutner.name>
Tue, 2 Dec 2014 07:42:21 +0000 (08:42 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 2 Dec 2014 07:42:53 +0000 (08:42 +0100)
fixes #7901

doc/7-configuring-icinga-2.md
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_mysql/idomysqlconnection.ti

index 63eac3350072245d57d4edb69a0ce333323572d9..877bc62f7d173084bbc46e71fa0da25a71c3623e 100644 (file)
@@ -1409,6 +1409,7 @@ Attributes:
   ----------------|----------------
   host            |**Optional.** MySQL database host address. Defaults to "localhost".
   port            |**Optional.** MySQL database port. Defaults to 3306.
+  socket_path     |**Optional.** MySQL socket path.
   user            |**Optional.** MySQL database user with read/write permission to the icinga database. Defaults to "icinga".
   password        |**Optional.** MySQL database user's password. Defaults to "icinga".
   database        |**Optional.** MySQL database name. Defaults to "icinga".
index 68da0bb9ef5387e8229f7a62c061ea425c33b5f8..49345b5038c5a47ece752e5e01e2f6e6975ae5c4 100644 (file)
@@ -179,17 +179,19 @@ void IdoMysqlConnection::Reconnect(void)
 
                ClearIDCache();
 
-               String ihost, iuser, ipasswd, idb;
-               const char *host, *user , *passwd, *db;
+               String ihost, isocket_path, iuser, ipasswd, idb;
+               const char *host, *socket_path, *user , *passwd, *db;
                long port;
 
                ihost = GetHost();
+               isocket_path = GetSocketPath();
                iuser = GetUser();
                ipasswd = GetPassword();
                idb = GetDatabase();
 
                host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
                port = GetPort();
+               socket_path = (!isocket_path.IsEmpty()) ? isocket_path.CStr() : NULL;
                user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
                passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
                db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
@@ -202,7 +204,7 @@ void IdoMysqlConnection::Reconnect(void)
                        BOOST_THROW_EXCEPTION(std::bad_alloc());
                }
 
-               if (!mysql_real_connect(&m_Connection, host, user, passwd, db, port, NULL, CLIENT_FOUND_ROWS)) {
+               if (!mysql_real_connect(&m_Connection, host, user, passwd, db, port, socket_path, CLIENT_FOUND_ROWS)) {
                        Log(LogCritical, "IdoMysqlConnection")
                            << "Connection to database '" << db << "' with user '" << user << "' on '" << host << ":" << port
                            << "' failed: \"" << mysql_error(&m_Connection) << "\"";
index 5cfa2ad46894fdc36bad7fe066dee94e6e0134b0..e90dd6a930a58bf398037c6c683b95d6893a46dd 100644 (file)
@@ -30,6 +30,7 @@ class IdoMysqlConnection : DbConnection
        [config] int port {
                default {{{ return 3306; }}}
        };
+       [config] String socket_path;
        [config] String user {
                default {{{ return "icinga"; }}}
        };