[Quickfix-developers] Database connections not closing
Brought to you by:
orenmnero
|
From: Sean K. <sea...@pi...> - 2006-04-08 17:08:22
|
Hello All,
I just recently noticed that when I shut down my engine for the evening =
the connections to the db are not closing out properly. It turns out =
there is an issue in the destroy function of the DatabaseConnectionPool =
class:
bool destroy( T* pConnection )
{
if( !m_poolConnections )
{
delete pConnection;
return true;
}
const DatabaseConnectionID& id =3D pConnection->connectionID();
if( m_connections.find( id ) =3D=3D m_connections.end() )
return false;
Connection connection =3D m_connections[id];
if( connection.first !=3D pConnection )
return false;
connection.second--;
if( connection.second =3D=3D 0 )
{
m_connections.erase( id );
delete pConnection;
}
return true;
}
The issue appears to be decrementing the ref count in the local =
variable. The fix I've applied locally to resolve the issue is:
bool destroy( T* pConnection )
{
if( !m_poolConnections )
{
delete pConnection;
return true;
}
const DatabaseConnectionID& id =3D pConnection->connectionID();
if( m_connections.find( id ) =3D=3D m_connections.end() )
return false;
if( m_connections[id].first !=3D pConnection )
return false;
m_connections[id].second--;
if( m_connections[id].second =3D=3D 0 )
{
m_connections.erase( id );
delete pConnection;
}
return true;
}
Hopefully this is a satisfactory fix for the problem...
Regards,
Sean Kirkpatrick
|