POCO SQLite Data Connector hangs #2108

This commit is contained in:
Alex Fabijanic 2018-02-09 08:57:37 -06:00
parent 5fa3d6094e
commit 6844c65d84
3 changed files with 16 additions and 39 deletions

View File

@ -17,8 +17,7 @@
#include "Poco/SQL/SQLite/SQLiteStatementImpl.h"
#include "Poco/SQL/SQLite/SQLiteException.h"
#include "Poco/SQL/Session.h"
#include "Poco/ActiveMethod.h"
#include "Poco/ActiveResult.h"
#include "Poco/Stopwatch.h"
#include "Poco/String.h"
#include "Poco/Mutex.h"
#include "Poco/SQL/SQLException.h"
@ -140,32 +139,6 @@ bool SessionImpl::isTransactionIsolation(Poco::UInt32 ti) const
}
class ActiveConnector
{
public:
ActiveConnector(const std::string& connectString, sqlite3** ppDB):
connect(this, &ActiveConnector::connectImpl),
_connectString(connectString),
_ppDB(ppDB)
{
poco_check_ptr(_ppDB);
}
ActiveMethod<int, void, ActiveConnector> connect;
private:
ActiveConnector();
inline int connectImpl()
{
return sqlite3_open_v2(_connectString.c_str(), _ppDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
}
std::string _connectString;
sqlite3** _ppDB;
};
void SessionImpl::open(const std::string& connect)
{
if (connect != connectionString())
@ -181,16 +154,20 @@ void SessionImpl::open(const std::string& connect)
try
{
ActiveConnector connector(connectionString(), &_pDB);
ActiveResult<int> result = connector.connect();
if (!result.tryWait(static_cast<long>(getLoginTimeout() * 1000)))
throw ConnectionFailedException("Timed out.");
int rc = result.data();
if (rc != 0)
int rc = 0;
size_t tout = getLoginTimeout();
Stopwatch sw; sw.start();
while (true)
{
close();
Utility::throwException(_pDB, rc);
rc = sqlite3_open_v2(connectionString().c_str(), &_pDB,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
if (rc == SQLITE_OK) break;
if (sw.elapsedSeconds() >= tout)
{
close();
Utility::throwException(_pDB, rc);
}
else Thread::sleep(10);
}
}
catch (SQLiteException& ex)

2
gradle

@ -1 +1 @@
Subproject commit 05a8d4d93581b2e780bad84f8f9178b8a4267eda
Subproject commit 73b60316d69e239902711f32dca95f6d97aa257c

@ -1 +1 @@
Subproject commit 26b1673caad94a702b6d694f48f917a283b30777
Subproject commit b42dcf2175f30e0c21dc9a684f0b9670f4ed09c8