namespace isc {
namespace db {
-std::string MySqlConnection::KEA_ADMIN_ = KEA_ADMIN;
+static MySqlLibraryInit init;
-int MySqlHolder::atexit_ = [] {
- return atexit([] { mysql_library_end(); });
-}();
+std::string MySqlConnection::KEA_ADMIN_ = KEA_ADMIN;
/// @todo: Migrate this default value to src/bin/dhcpX/simple_parserX.cc
const int MYSQL_DEFAULT_CONNECTION_TIMEOUT = 5; // seconds
}
private:
- /// @brief Variable used for its static property to call atexit() once.
- static int atexit_;
/// @brief Initialization context
MYSQL* mysql_;
static std::string KEA_ADMIN_;
};
+/// @brief Structure used to initialize and clean up after MySQL library.
+struct MySqlLibraryInit {
+ /// @brief Constructor.
+ MySqlLibraryInit() {
+ mysql_library_init(0, 0, 0);
+ }
+
+ /// @brief Destructor.
+ ~MySqlLibraryInit() {
+ mysql_library_end();
+ }
+};
+
} // end of isc::db namespace
} // end of isc namespace