File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,10 @@ function startListening(socket) {
184184function replaceHandle ( self , newHandle ) {
185185 const state = self [ kStateSymbol ] ;
186186 const oldHandle = state . handle ;
187-
187+ // Sync the old handle state to new handle
188+ if ( ! oldHandle . hasRef ( ) && typeof newHandle . unref === 'function' ) {
189+ newHandle . unref ( ) ;
190+ }
188191 // Set up the handle that we got from primary.
189192 newHandle . lookup = oldHandle . lookup ;
190193 newHandle . bind = oldHandle . bind ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common' ) ;
3+ const dgram = require ( 'dgram' ) ;
4+ const cluster = require ( 'cluster' ) ;
5+ const assert = require ( 'assert' ) ;
6+
7+ if ( common . isWindows )
8+ common . skip ( 'dgram clustering is currently not supported on Windows.' ) ;
9+
10+ if ( cluster . isPrimary ) {
11+ cluster . fork ( ) ;
12+ } else {
13+ const socket = dgram . createSocket ( 'udp4' ) ;
14+ socket . unref ( ) ;
15+ socket . bind ( ) ;
16+ socket . on ( 'listening' , common . mustCall ( ( ) => {
17+ const sockets = process . getActiveResourcesInfo ( ) . filter ( ( item ) => {
18+ return item === 'UDPWrap' ;
19+ } ) ;
20+ assert . ok ( sockets . length === 0 ) ;
21+ process . disconnect ( ) ;
22+ } ) ) ;
23+ }
You can’t perform that action at this time.
0 commit comments