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) {
184
184
function replaceHandle ( self , newHandle ) {
185
185
const state = self [ kStateSymbol ] ;
186
186
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
+ }
188
191
// Set up the handle that we got from primary.
189
192
newHandle . lookup = oldHandle . lookup ;
190
193
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
+
6
+ // Test if the worker process exits.
7
+
8
+ if ( cluster . isPrimary ) {
9
+ cluster . fork ( ) ;
10
+ } else {
11
+ const socket = dgram . createSocket ( 'udp4' ) ;
12
+ socket . unref ( ) ;
13
+ socket . bind ( ) ;
14
+ socket . on ( 'listening' , common . mustCall ( ( ) => {
15
+ // Do not keep loop alive
16
+ process . channel . unref ( ) ;
17
+ } ) ) ;
18
+ }
You can’t perform that action at this time.
0 commit comments