mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-03 12:18:11 +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;
|
||||
if (type == ClientType::PostgreSQL)
|
||||
{
|
||||
newConnection();
|
||||
_loop->runInLoop([this](){
|
||||
_connectionHolder=newConnection();
|
||||
});
|
||||
}
|
||||
else if (type == ClientType::Mysql)
|
||||
{
|
||||
newConnection();
|
||||
_loop->runInLoop([this](){
|
||||
_connectionHolder=newConnection();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -207,7 +211,7 @@ DbConnectionPtr DbClientLockFree::newConnection()
|
||||
auto thisPtr = weakPtr.lock();
|
||||
if (!thisPtr)
|
||||
return;
|
||||
thisPtr->newConnection();
|
||||
thisPtr->_connectionHolder=thisPtr->newConnection();
|
||||
});
|
||||
});
|
||||
connPtr->setOkCallback([weakPtr](const DbConnectionPtr &okConnPtr) {
|
||||
|
@ -60,6 +60,7 @@ class DbClientLockFree : public DbClient, public std::enable_shared_from_this<Db
|
||||
DbConnectionPtr newConnection();
|
||||
|
||||
DbConnectionPtr _connection;
|
||||
DbConnectionPtr _connectionHolder;
|
||||
|
||||
struct SqlCmd
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user