-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Poco::Data::PostgreSQL::SessionHandle::disconnect() implementation does not free (PQfinish) PGconn* _pConnection, if the connection has failed:
SessionHandle::~SessionHandle()
{
try
{
disconnect();
}
catch (...)
{
}
}
void SessionHandle::disconnect()
{
Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex);
if (isConnectedNoLock())
{
PQfinish(_pConnection);
_pConnection = 0;
_connectionString = std::string();
_inTransaction= false;
_isAutoCommit = true;
_isAsynchronousCommit = false;
_tranactionIsolationLevel = Session::TRANSACTION_READ_COMMITTED;
}
}
bool SessionHandle::isConnectedNoLock() const
{
// DO NOT ACQUIRE THE MUTEX IN PRIVATE METHODS
if (_pConnection && PQstatus(_pConnection) == CONNECTION_OK)
{
return true;
}
return false;
}
As stated by libpq documentation:
Note that even if the server connection attempt fails (as indicated by PQstatus), the application should call PQfinish to free the memory used by the PGconn object. The PGconn pointer must not be used again after PQfinish has been called.
Reactions are currently unavailable