files for 1.4.7 branch

This commit is contained in:
Guenter Obiltschnig
2014-10-02 00:09:44 +02:00
parent 19e3c8724f
commit 2ce03fbb95
1401 changed files with 177908 additions and 32791 deletions

View File

@@ -1,7 +1,7 @@
//
// SesssionHandle.cpp
//
// $Id: //poco/1.4/Data/MySQL/src/SessionHandle.cpp#1 $
// $Id: //poco/1.4/Data/MySQL/src/SessionHandle.cpp#2 $
//
// Library: Data/MySQL
// Package: MySQL
@@ -35,7 +35,11 @@
#include "Poco/Data/MySQL/SessionHandle.h"
#include "Poco/SingletonHolder.h"
#include <cstring>
#ifdef POCO_OS_FAMILY_UNIX
#include <pthread.h>
#endif
namespace Poco {
@@ -43,6 +47,42 @@ 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);
@@ -51,6 +91,9 @@ SessionHandle::SessionHandle(MYSQL* mysql)
{
throw ConnectionException("mysql_init error");
}
#ifdef POCO_OS_FAMILY_UNIX
ThreadCleanupHelper::instance().init();
#endif
}