mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-04 20:57:50 +08:00
Fix a bug in the DbClientLockFree class
This commit is contained in:
parent
358e45598b
commit
5629efa910
@ -46,11 +46,15 @@ DbClientLockFree::DbClientLockFree(const std::string &connInfo, trantor::EventLo
|
|||||||
LOG_TRACE << "type=" << (int)type;
|
LOG_TRACE << "type=" << (int)type;
|
||||||
if (type == ClientType::PostgreSQL)
|
if (type == ClientType::PostgreSQL)
|
||||||
{
|
{
|
||||||
newConnection();
|
_loop->runInLoop([this](){
|
||||||
|
_connectionHolder=newConnection();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (type == ClientType::Mysql)
|
else if (type == ClientType::Mysql)
|
||||||
{
|
{
|
||||||
newConnection();
|
_loop->runInLoop([this](){
|
||||||
|
_connectionHolder=newConnection();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -207,7 +211,7 @@ DbConnectionPtr DbClientLockFree::newConnection()
|
|||||||
auto thisPtr = weakPtr.lock();
|
auto thisPtr = weakPtr.lock();
|
||||||
if (!thisPtr)
|
if (!thisPtr)
|
||||||
return;
|
return;
|
||||||
thisPtr->newConnection();
|
thisPtr->_connectionHolder=thisPtr->newConnection();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
connPtr->setOkCallback([weakPtr](const DbConnectionPtr &okConnPtr) {
|
connPtr->setOkCallback([weakPtr](const DbConnectionPtr &okConnPtr) {
|
||||||
|
@ -60,6 +60,7 @@ class DbClientLockFree : public DbClient, public std::enable_shared_from_this<Db
|
|||||||
DbConnectionPtr newConnection();
|
DbConnectionPtr newConnection();
|
||||||
|
|
||||||
DbConnectionPtr _connection;
|
DbConnectionPtr _connection;
|
||||||
|
DbConnectionPtr _connectionHolder;
|
||||||
|
|
||||||
struct SqlCmd
|
struct SqlCmd
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user