MCPcopy Create free account
hub / github.com/nodejs/node / _disconnect

Function _disconnect

lib/internal/cluster/child.js:254–285  ·  view source on GitHub ↗
(primaryInitiated)

Source from the content-addressed store, hash-verified

252}
253
254function _disconnect(primaryInitiated) {
255 this.exitedAfterDisconnect = true;
256 let waitingCount = 1;
257
258 function checkWaitingCount() {
259 waitingCount--;
260
261 if (waitingCount === 0) {
262 // If disconnect is worker initiated, wait for ack to be sure
263 // exitedAfterDisconnect is properly set in the primary, otherwise, if
264 // it's primary initiated there's no need to send the
265 // exitedAfterDisconnect message
266 if (primaryInitiated) {
267 process.disconnect();
268 } else {
269 send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
270 }
271 }
272 }
273
274 for (const handle of handles.values()) {
275 waitingCount++;
276
277 if (handle[owner_symbol])
278 handle[owner_symbol].close(checkWaitingCount);
279 else
280 handle.close(checkWaitingCount);
281 }
282
283 handles.clear();
284 checkWaitingCount();
285}
286
287// Extend generic Worker with methods specific to worker processes.
288Worker.prototype.disconnect = function() {

Callers

nothing calls this directly

Calls 4

checkWaitingCountFunction · 0.85
closeMethod · 0.65
clearMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected