File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -47,19 +47,25 @@ if (cluster.isMaster) {
4747 process . on ( 'message' , function ( msg , handle ) {
4848 if ( msg . message && msg . message === 'listen' ) {
4949 assert ( msg . port ) ;
50- const client1 = net . connect ( { host : 'localhost' , port : msg . port } ) ;
51- const client2 = net . connect ( { host : 'localhost' , port : msg . port } ) ;
50+ const client1 = net . connect ( {
51+ host : 'localhost' ,
52+ port : msg . port
53+ } , function ( ) {
54+ const client2 = net . connect ( {
55+ host : 'localhost' ,
56+ port : msg . port
57+ } , function ( ) {
58+ client1 . on ( 'close' , onclose ) ;
59+ client2 . on ( 'close' , onclose ) ;
60+ client1 . end ( ) ;
61+ client2 . end ( ) ;
62+ } ) ;
63+ } ) ;
5264 let waiting = 2 ;
53- client1 . on ( 'close' , onclose ) ;
54- client2 . on ( 'close' , onclose ) ;
5565 function onclose ( ) {
5666 if ( -- waiting === 0 )
5767 cluster . worker . disconnect ( ) ;
5868 }
59- setTimeout ( function ( ) {
60- client1 . end ( ) ;
61- client2 . end ( ) ;
62- } , 50 ) ;
6369 } else {
6470 process . send ( 'reply' , handle ) ;
6571 }
You can’t perform that action at this time.
0 commit comments