Skip to content

Commit

Permalink
Make spare connections more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 8, 2018
1 parent e0cc66c commit 58da975
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -801,7 +801,12 @@ Set a single custom expression variable.

int maxConcurrentConnectionsPerPool() const;
%Docstring
The maximum number of concurrent connections per connections pool
The maximum number of concurrent connections per connections pool.

.. note::

QGIS may in some situations allocate more than this amount
of connections to avoid deadlocks.

.. versionadded:: 3.4
%End
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -85,7 +85,7 @@
#include <cpl_conv.h> // for setting gdal options
#include <sqlite3.h>

#define CONN_POOL_MAX_CONCURRENT_CONNS 6
#define CONN_POOL_MAX_CONCURRENT_CONNS 4

QObject *ABISYM( QgsApplication::mFileOpenEventReceiver );
QStringList ABISYM( QgsApplication::mFileOpenEventList );
Expand Down
5 changes: 4 additions & 1 deletion src/core/qgsapplication.h
Expand Up @@ -733,7 +733,10 @@ class CORE_EXPORT QgsApplication : public QApplication
static void setCustomVariable( const QString &name, const QVariant &value );

/**
* The maximum number of concurrent connections per connections pool
* The maximum number of concurrent connections per connections pool.
*
* \note QGIS may in some situations allocate more than this amount
* of connections to avoid deadlocks.
*
* \since QGIS 3.4
*/
Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsconnectionpool.h
Expand Up @@ -31,6 +31,7 @@


#define CONN_POOL_EXPIRATION_TIME 60 // in seconds
#define CONN_POOL_SPARE_CONNECTIONS 2 // number of spare connections in case all the base connections are used but we have a nested request with the risk of a deadlock


/**
Expand Down Expand Up @@ -67,7 +68,7 @@ class QgsConnectionPoolGroup

QgsConnectionPoolGroup( const QString &ci )
: connInfo( ci )
, sem( QgsApplication::instance()->maxConcurrentConnectionsPerPool() )
, sem( QgsApplication::instance()->maxConcurrentConnectionsPerPool() + CONN_POOL_SPARE_CONNECTIONS )
{
}

Expand Down

0 comments on commit 58da975

Please sign in to comment.