Fix pool queue dequeuing loop
This resolves a problem introduced with the pool.reconfigure() enhancement.
This commit is contained in:
parent
901c50c632
commit
b7abd67128
13
lib/pool.js
13
lib/pool.js
|
@ -27,14 +27,17 @@ const util = require('util');
|
||||||
// _checkRequestQueue()
|
// _checkRequestQueue()
|
||||||
// When a connection is returned to the pool, this method is called (via an
|
// When a connection is returned to the pool, this method is called (via an
|
||||||
// event handler) to determine when requests for connections should be
|
// event handler) to determine when requests for connections should be
|
||||||
// completed and cancels any timeout that may have been associated with the
|
// resumed and cancels any timeout that may have been associated with the
|
||||||
// request. This method is also called from reconfigure() so that waiting
|
// request. This method is also called from reconfigure() so that waiting
|
||||||
// connection-requests can be processed.
|
// connection requests can be processed. Note the use of a local variable for
|
||||||
|
// the number of connections out. This is because the connection requests will
|
||||||
|
// not resume until after the loop is finished, and therefore the number of
|
||||||
|
// connections the pool thinks is out will not be incremented.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
function _checkRequestQueue() {
|
function _checkRequestQueue() {
|
||||||
while (this._connRequestQueue.length > 0 &&
|
let connectionsOut = this._connectionsOut;
|
||||||
this._connectionsOut < this.poolMax) {
|
while (this._connRequestQueue.length > 0 && connectionsOut < this.poolMax) {
|
||||||
// process the payload
|
connectionsOut += 1;
|
||||||
const payload = this._connRequestQueue.shift();
|
const payload = this._connRequestQueue.shift();
|
||||||
if (this._enableStatistics) {
|
if (this._enableStatistics) {
|
||||||
this._totalRequestsDequeued += 1;
|
this._totalRequestsDequeued += 1;
|
||||||
|
|
Loading…
Reference in New Issue