mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
dgram: sync the old handle state to new handle
PR-URL: https://github.com/nodejs/node/pull/46041 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
parent
9eb363a3e0
commit
6d49f46b48
@ -184,7 +184,10 @@ function startListening(socket) {
|
||||
function replaceHandle(self, newHandle) {
|
||||
const state = self[kStateSymbol];
|
||||
const oldHandle = state.handle;
|
||||
|
||||
// Sync the old handle state to new handle
|
||||
if (!oldHandle.hasRef() && typeof newHandle.unref === 'function') {
|
||||
newHandle.unref();
|
||||
}
|
||||
// Set up the handle that we got from primary.
|
||||
newHandle.lookup = oldHandle.lookup;
|
||||
newHandle.bind = oldHandle.bind;
|
||||
|
||||
23
test/parallel/test-dgram-unref-in-cluster.js
Normal file
23
test/parallel/test-dgram-unref-in-cluster.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const dgram = require('dgram');
|
||||
const cluster = require('cluster');
|
||||
const assert = require('assert');
|
||||
|
||||
if (common.isWindows)
|
||||
common.skip('dgram clustering is currently not supported on Windows.');
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
cluster.fork();
|
||||
} else {
|
||||
const socket = dgram.createSocket('udp4');
|
||||
socket.unref();
|
||||
socket.bind();
|
||||
socket.on('listening', common.mustCall(() => {
|
||||
const sockets = process.getActiveResourcesInfo().filter((item) => {
|
||||
return item === 'UDPWrap';
|
||||
});
|
||||
assert.ok(sockets.length === 0);
|
||||
process.disconnect();
|
||||
}));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user