postgres connection pool: fix race when a connection is already acquired while pool is still being constructed

This commit is contained in:
Juergen E. Fischer 2015-05-28 15:03:10 +02:00
parent ecbe0e43f4
commit 1e96813132

View File

@ -14,14 +14,23 @@
***************************************************************************/
#include "qgspostgresconnpool.h"
#include "qgspostgresconn.h"
QgsPostgresConnPool* QgsPostgresConnPool::instance()
{
static QgsPostgresConnPool sInstance;
return &sInstance;
static QgsPostgresConnPool *sInstance = 0;
if ( !sInstance )
{
static QMutex m;
m.lock();
if ( !sInstance )
sInstance = new QgsPostgresConnPool();
m.unlock();
}
return sInstance;
}
QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool<QgsPostgresConn*, QgsPostgresConnPoolGroup>()