mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
removed automatic registration as it can cause a deadlock in mysql_library_init
This commit is contained in:
parent
8a13c50e63
commit
ce4341e96b
@ -24,12 +24,6 @@
|
||||
#include "Poco/Data/Connector.h"
|
||||
|
||||
|
||||
// Note: to avoid static (de)initialization problems,
|
||||
// during connector automatic (un)registration, it is
|
||||
// best to have this as a macro.
|
||||
#define POCO_DATA_MYSQL_CONNECTOR_NAME "mysql"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace MySQL {
|
||||
@ -66,62 +60,4 @@ public:
|
||||
} } } // namespace Poco::Data::MySQL
|
||||
|
||||
|
||||
//
|
||||
// Automatic Connector registration
|
||||
//
|
||||
|
||||
struct MySQL_API MySQLConnectorRegistrator
|
||||
/// Connector registering class.
|
||||
/// A global instance of this class is instantiated
|
||||
/// with sole purpose to automatically register the
|
||||
/// MySQL connector with central Poco Data registry.
|
||||
{
|
||||
MySQLConnectorRegistrator()
|
||||
/// Calls Poco::Data::MySQL::registerConnector();
|
||||
{
|
||||
Poco::Data::MySQL::Connector::registerConnector();
|
||||
}
|
||||
|
||||
~MySQLConnectorRegistrator()
|
||||
/// Calls Poco::Data::MySQL::unregisterConnector();
|
||||
{
|
||||
try
|
||||
{
|
||||
Poco::Data::MySQL::Connector::unregisterConnector();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
poco_unexpected();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIB_INIT)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(__GNUC__)
|
||||
extern "C" const struct MySQL_API MySQLConnectorRegistrator pocoMySQLConnectorRegistrator;
|
||||
#if defined(MySQL_EXPORTS)
|
||||
#if defined(_WIN64)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:"#s))
|
||||
#elif defined(_WIN32)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:_"#s))
|
||||
#endif
|
||||
#else // !MySQL_EXPORTS
|
||||
#if defined(_WIN64)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:"#s))
|
||||
#elif defined(_WIN32)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:_"#s))
|
||||
#endif
|
||||
#endif // MySQL_EXPORTS
|
||||
#else // !POCO_OS_FAMILY_WINDOWS
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) extern "C" const struct MySQLConnectorRegistrator s;
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
POCO_DATA_MYSQL_FORCE_SYMBOL(pocoMySQLConnectorRegistrator)
|
||||
#endif // POCO_NO_AUTOMATIC_LIB_INIT
|
||||
|
||||
//
|
||||
// End automatic Connector registration
|
||||
//
|
||||
|
||||
|
||||
#endif // Data_MySQL_Connector_INCLUDED
|
||||
|
@ -21,15 +21,12 @@
|
||||
#include <mysql.h>
|
||||
|
||||
|
||||
const MySQLConnectorRegistrator pocoMySQLConnectorRegistrator;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace MySQL {
|
||||
|
||||
|
||||
std::string Connector::KEY(POCO_DATA_MYSQL_CONNECTOR_NAME);
|
||||
std::string Connector::KEY("mysql");
|
||||
|
||||
|
||||
Connector::Connector()
|
||||
@ -41,12 +38,13 @@ Connector::~Connector()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const std::string& Connector::name() const
|
||||
{
|
||||
static const std::string n(POCO_DATA_MYSQL_CONNECTOR_NAME);
|
||||
return n;
|
||||
return KEY;
|
||||
}
|
||||
|
||||
|
||||
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
|
||||
std::size_t timeout)
|
||||
{
|
||||
@ -67,7 +65,7 @@ void Connector::registerConnector()
|
||||
|
||||
void Connector::unregisterConnector()
|
||||
{
|
||||
Poco::Data::SessionFactory::instance().remove(POCO_DATA_MYSQL_CONNECTOR_NAME);
|
||||
Poco::Data::SessionFactory::instance().remove(KEY);
|
||||
mysql_library_end();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user