added Poco::Data::Session::isGood()

This commit is contained in:
Günter Obiltschnig
2020-01-13 20:13:27 +01:00
parent c04a1f28d9
commit 43b79ffdbe
13 changed files with 200 additions and 44 deletions

View File

@@ -42,23 +42,23 @@ public:
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;
@@ -192,4 +192,11 @@ void SessionHandle::reset()
}
bool SessionHandle::ping()
{
int rc = mysql_ping(_pHandle);
return rc == 0;
}
} } } // namespace Poco::Data::MySQL