File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,17 @@ const util = require('util');
27
27
// _checkRequestQueue()
28
28
// When a connection is returned to the pool, this method is called (via an
29
29
// event handler) to determine when requests for connections should be
30
- // completed and cancels any timeout that may have been associated with the
30
+ // resumed and cancels any timeout that may have been associated with the
31
31
// request. This method is also called from reconfigure() so that waiting
32
- // connection-requests can be processed.
32
+ // connection requests can be processed. Note the use of a local variable for
33
+ // the number of connections out. This is because the connection requests will
34
+ // not resume until after the loop is finished, and therefore the number of
35
+ // connections the pool thinks is out will not be incremented.
33
36
//-----------------------------------------------------------------------------
34
37
function _checkRequestQueue ( ) {
35
- while ( this . _connRequestQueue . length > 0 &&
36
- this . _connectionsOut < this . poolMax ) {
37
- // process the payload
38
+ let connectionsOut = this . _connectionsOut ;
39
+ while ( this . _connRequestQueue . length > 0 && connectionsOut < this . poolMax ) {
40
+ connectionsOut += 1 ;
38
41
const payload = this . _connRequestQueue . shift ( ) ;
39
42
if ( this . _enableStatistics ) {
40
43
this . _totalRequestsDequeued += 1 ;
You can’t perform that action at this time.
0 commit comments