Skip to content
Permalink
Browse files
Merge pull request #2078 from manisandro/connpoolfixes
Connection pool fixes
  • Loading branch information
mhugent committed May 26, 2015
2 parents e2edc54 + a6bf6e9 commit 930ad6825d65186195e7267ac8446a9e01db6466
Showing with 17 additions and 14 deletions.
  1. +15 −2 src/core/qgsconnectionpool.h
  2. +0 −8 src/providers/ogr/qgsogrconnpool.cpp
  3. +0 −2 src/providers/ogr/qgsogrconnpool.h
  4. +2 −2 src/providers/ogr/qgsogrprovider.cpp
@@ -123,9 +123,8 @@ class QgsConnectionPoolGroup

void release( T conn )
{
acquiredConns.removeAll( conn );

connMutex.lock();
acquiredConns.removeAll( conn );
Item i;
i.c = conn;
i.lastUsedTime = QTime::currentTime();
@@ -255,6 +254,20 @@ class QgsConnectionPool
group->release( conn );
}

//! Invalidates all connections to the specified resource.
//! The internal state of certain handles (for instance OGR) are altered
//! when a dataset is modified. Consquently, all open handles need to be
//! invalidated when such datasets are changed to ensure the handles are
//! refreshed. See the OGR provider for an example where this is needed.
void invalidateConnections( const QString& connInfo )
{
mMutex.lock();
if ( mGroups.contains( connInfo ) )
mGroups[connInfo]->invalidateConnections();
mMutex.unlock();
}


protected:
T_Groups mGroups;
QMutex mMutex;
@@ -31,11 +31,3 @@ QgsOgrConnPool::~QgsOgrConnPool()
{
QgsDebugCall;
}

void QgsOgrConnPool::invalidateHandles( const QString& connInfo )
{
mMutex.lock();
if ( mGroups.contains( connInfo ) )
mGroups[connInfo]->invalidateConnections();
mMutex.unlock();
}
@@ -79,8 +79,6 @@ class QgsOgrConnPool : public QgsConnectionPool<QgsOgrConn*, QgsOgrConnPoolGroup
public:
static QgsOgrConnPool* instance();

void invalidateHandles( const QString& connInfo );

protected:
Q_DISABLE_COPY( QgsOgrConnPool )

@@ -741,7 +741,7 @@ OGRwkbGeometryType QgsOgrProvider::getOgrGeomType( OGRLayerH ogrLayer )

void QgsOgrProvider::loadFields()
{
QgsOgrConnPool::instance()->invalidateHandles( filePath() );
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
//the attribute fields need to be read again when the encoding changes
mAttributeFields.clear();

@@ -2524,7 +2524,7 @@ void QgsOgrProvider::recalculateFeatureCount()
OGR_L_SetSpatialFilter( ogrLayer, filter );
}

QgsOgrConnPool::instance()->invalidateHandles( filePath() );
QgsOgrConnPool::instance()->invalidateConnections( filePath() );
}

OGRwkbGeometryType QgsOgrProvider::ogrWkbSingleFlatten( OGRwkbGeometryType type )

0 comments on commit 930ad68

Please sign in to comment.