changes for 1.4.6p3

This commit is contained in:
Guenter Obiltschnig
2014-04-02 10:06:07 +02:00
parent d0b3c779da
commit f3b9e3bbe8
14 changed files with 127 additions and 302 deletions

View File

@@ -1,7 +1,7 @@
//
// SesssionHandle.cpp
//
// $Id: //poco/1.4/Data/MySQL/src/SessionHandle.cpp#2 $
// $Id: //poco/1.4/Data/MySQL/src/SessionHandle.cpp#1 $
//
// Library: Data/MySQL
// Package: MySQL
@@ -35,11 +35,7 @@
#include "Poco/Data/MySQL/SessionHandle.h"
#include "Poco/SingletonHolder.h"
#include <cstring>
#ifdef POCO_OS_FAMILY_UNIX
#include <pthread.h>
#endif
namespace Poco {
@@ -47,42 +43,6 @@ namespace Data {
namespace MySQL {
#ifdef POCO_OS_FAMILY_UNIX
class ThreadCleanupHelper
{
public:
ThreadCleanupHelper()
{
if (pthread_key_create(&_key, &ThreadCleanupHelper::cleanup) != 0)
throw Poco::SystemException("cannot create TLS key for mysql cleanup");
}
void init()
{
if (pthread_setspecific(_key, reinterpret_cast<void*>(1)))
throw Poco::SystemException("cannot set TLS key for mysql cleanup");
}
static ThreadCleanupHelper& instance()
{
return *_sh.get();
}
static void cleanup(void* data)
{
mysql_thread_end();
}
private:
pthread_key_t _key;
static Poco::SingletonHolder<ThreadCleanupHelper> _sh;
};
Poco::SingletonHolder<ThreadCleanupHelper> ThreadCleanupHelper::_sh;
#endif
SessionHandle::SessionHandle(MYSQL* mysql)
{
h = mysql_init(mysql);
@@ -91,9 +51,6 @@ SessionHandle::SessionHandle(MYSQL* mysql)
{
throw ConnectionException("mysql_init error");
}
#ifdef POCO_OS_FAMILY_UNIX
ThreadCleanupHelper::instance().init();
#endif
}