Skip to content
Permalink
Browse files

postgres connection pool: fix race when a connection is already acqui…

…red while pool is still being constructed

(cherry picked from commit 1e96813)
  • Loading branch information
jef-n committed May 28, 2015
1 parent 87adfbe commit b97d46cd99ea02c5802754f8df5a5da45810cc15
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/providers/postgres/qgspostgresconnpool.cpp
@@ -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>()

0 comments on commit b97d46c

Please sign in to comment.
You can’t perform that action at this time.