File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-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 ( cluster . isPrimary ) {
8+ cluster . fork ( ) ;
9+ } else {
10+ const socket = dgram . createSocket ( 'udp4' ) ;
11+ socket . unref ( ) ;
12+ socket . bind ( ) ;
13+ socket . on ( 'listening' , common . mustCall ( ( ) => {
14+ const sockets = process . _getActiveHandles ( ) . filter ( ( item ) => item instanceof dgram . Socket ) ;
15+ assert . ok ( sockets . length === 0 ) ;
16+ process . disconnect ( ) ;
17+ } ) ) ;
18+ }
You can’t perform that action at this time.
0 commit comments