Skip to content
Browse files
postgres connection pool: fix race when a connection is already acqui…
…red while pool is still being constructed
  • Loading branch information
jef-n committed May 28, 2015
1 parent ecbe0e4 commit 1e9681313284537d40fdec9039e8da9b755d0a60
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;
if ( !sInstance )
sInstance = new QgsPostgresConnPool();

return sInstance;

QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool<QgsPostgresConn*, QgsPostgresConnPoolGroup>()

2 comments on commit 1e96813


This comment has been minimized.

Copy link

@wonder-sk wonder-sk replied May 29, 2015

Just wondering - was that a windows issue? From what I read the static variable initialization should be thread-safe with GCC, but not so with VC++


This comment has been minimized.

Copy link
Member Author

@jef-n jef-n replied May 31, 2015

Not sure. But it that the case the 'fix' is probably not real one and c550af2 is a better fix. It isn't reliably reproducable.

Please sign in to comment.