Merge branch '2.3' into 2.4

This commit is contained in:
Esa Korhonen
2019-06-27 18:56:25 +03:00
4 changed files with 54 additions and 16 deletions

View File

@ -91,18 +91,33 @@ PamClientSession* PamClientSession::create(const PamInstance& inst)
{
// This handle is only used from one thread, can define no_mutex.
sqlite3* dbhandle = NULL;
int db_flags = SQLITE_OPEN_READONLY | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_NOMUTEX
| SQLITE_OPEN_URI;
if (sqlite3_open_v2(inst.m_dbname.c_str(), &dbhandle, db_flags, NULL) == SQLITE_OK)
bool error = false;
int db_flags = SQLITE_OPEN_READONLY | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_NOMUTEX;
const char* filename = inst.m_dbname.c_str();
if (sqlite3_open_v2(filename, &dbhandle, db_flags, NULL) == SQLITE_OK)
{
sqlite3_busy_timeout(dbhandle, 1000);
}
else
{
MXS_ERROR("Failed to open SQLite3 handle.");
if (dbhandle)
{
MXS_ERROR(SQLITE_OPEN_FAIL, filename, sqlite3_errmsg(dbhandle));
}
else
{
MXS_ERROR(SQLITE_OPEN_OOM, filename);
}
error = true;
}
PamClientSession* rval = NULL;
if (!dbhandle || (rval = new(std::nothrow) PamClientSession(dbhandle, inst)) == NULL)
if (!error && ((rval = new(std::nothrow) PamClientSession(dbhandle, inst)) == NULL))
{
error = true;
}
if (error)
{
sqlite3_close_v2(dbhandle);
}