mirror of https://github.com/xwiki-labs/cryptpad
fix an incorrect condition when checking for available server workers
Also, log when the RPC queue has a backlog and when it is drained
This commit is contained in:
parent
fff87fd42b
commit
b0af6b5488
|
@ -67,13 +67,14 @@ Workers.initialize = function (Env, config, _cb) {
|
|||
but this is a relatively easy way to make sure it's always up to date.
|
||||
We'll see how it performs in practice before optimizing.
|
||||
*/
|
||||
if (workers[temp] && Object.keys(workers[temp]).length < MAX_JOBS) {
|
||||
if (workers[temp] && Object.keys(workers[temp].tasks || {}).length < MAX_JOBS) {
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
var drained = true;
|
||||
var sendCommand = function (msg, _cb) {
|
||||
var index = getAvailableWorkerIndex();
|
||||
|
||||
|
@ -85,6 +86,13 @@ Workers.initialize = function (Env, config, _cb) {
|
|||
msg: msg,
|
||||
cb: _cb,
|
||||
});
|
||||
if (drained) {
|
||||
drained = false;
|
||||
Log.debug('WORKER_QUEUE_BACKLOG', {
|
||||
workers: workers.length,
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -117,7 +125,15 @@ Workers.initialize = function (Env, config, _cb) {
|
|||
if (!res.txid) { return; }
|
||||
response.handle(res.txid, [res.error, res.value]);
|
||||
delete state.tasks[res.txid];
|
||||
if (!queue.length) { return; }
|
||||
if (!queue.length) {
|
||||
if (!drained) {
|
||||
drained = true;
|
||||
Log.debug('WORKER_QUEUE_DRAINED', {
|
||||
workers: workers.length,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var nextMsg = queue.shift();
|
||||
/* `nextMsg` was at the top of the queue.
|
||||
|
|
Loading…
Reference in New Issue