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');
2727// _checkRequestQueue()
2828// When a connection is returned to the pool, this method is called (via an
2929// 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
3131// 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.
3336//-----------------------------------------------------------------------------
3437function _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 ;
3841 const payload = this . _connRequestQueue . shift ( ) ;
3942 if ( this . _enableStatistics ) {
4043 this . _totalRequestsDequeued += 1 ;
You can’t perform that action at this time.
0 commit comments