mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
change auto-reconnect
This commit is contained in:
parent
9a0018a03d
commit
12e4d68abf
@ -56,10 +56,28 @@ bool ConnectionManager::setConnectionsFromConfig(const Poco::Util::LayeredConfig
|
|||||||
dbConfig << "db=" << dbName << ";";
|
dbConfig << "db=" << dbName << ";";
|
||||||
dbConfig << "user=" << config.getString(firstKeyPart + ".db.user", "root") << ";";
|
dbConfig << "user=" << config.getString(firstKeyPart + ".db.user", "root") << ";";
|
||||||
dbConfig << "password=" << config.getString(firstKeyPart + ".db.password", "") << ";";
|
dbConfig << "password=" << config.getString(firstKeyPart + ".db.password", "") << ";";
|
||||||
dbConfig << "auto-reconnect=true";
|
dbConfig << "auto-reconnect=false";
|
||||||
|
|
||||||
setConnection(dbConfig.str(), type);
|
setConnection(dbConfig.str(), type);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Poco::Data::Session ConnectionManager::getConnection(ConnectionType type)
|
||||||
|
{
|
||||||
|
Poco::ScopedLock<Poco::FastMutex> _lock(mWorkingMutex);
|
||||||
|
|
||||||
|
if (CONNECTION_MYSQL_LOGIN_SERVER != type && CONNECTION_MYSQL_PHP_SERVER != type) {
|
||||||
|
addError(new ParamError("[ConnectionManager::getConnection]", "Connection Type unknown", std::to_string(type)));
|
||||||
|
throw Poco::NotFoundException("Connection Type unknown", std::to_string(type));
|
||||||
|
}
|
||||||
|
auto session = mSessionPools.getPool(mSessionPoolNames[type]).get();
|
||||||
|
if (!session.isConnected()) {
|
||||||
|
printf("reconnect called\n");
|
||||||
|
session.reconnect();
|
||||||
|
}
|
||||||
|
//std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S");
|
||||||
|
//printf("[getConnection] %s impl: %p\n", dateTimeString.data(), session.impl());
|
||||||
|
return session;
|
||||||
}
|
}
|
||||||
@ -35,18 +35,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Poco::Data::Session getConnection(ConnectionType type) {
|
//! \brief return connection from pool, check if connected in if not, call reconnect on it
|
||||||
Poco::ScopedLock<Poco::FastMutex> _lock(mWorkingMutex);
|
//!
|
||||||
|
//! In the past I used auto-reconnect but it didn't work everytime as expectet
|
||||||
if (CONNECTION_MYSQL_LOGIN_SERVER != type && CONNECTION_MYSQL_PHP_SERVER != type) {
|
Poco::Data::Session getConnection(ConnectionType type);
|
||||||
addError(new ParamError("[ConnectionManager::getConnection]", "Connection Type unknown", std::to_string(type)));
|
|
||||||
throw Poco::NotFoundException("Connection Type unknown", std::to_string(type));
|
|
||||||
}
|
|
||||||
auto session = mSessionPools.getPool(mSessionPoolNames[type]).get();
|
|
||||||
//std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d.%m.%y %H:%M:%S");
|
|
||||||
//printf("[getConnection] %s impl: %p\n", dateTimeString.data(), session.impl());
|
|
||||||
return session;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ConnectionManager();
|
ConnectionManager();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user