Commit 6f2e806 1 parent 27de369 commit 6f2e806 Copy full SHA for 6f2e806
File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,11 @@ function connectionListener(socket) {
294
294
295
295
httpSocketSetup ( socket ) ;
296
296
297
+ // Ensure that the server property of the socket is correctly set.
298
+ // See https://github.com/nodejs/node/issues/13435
299
+ if ( socket . server === null )
300
+ socket . server = this ;
301
+
297
302
// If the user has added a listener to the server,
298
303
// request, or response, then it's their responsibility.
299
304
// otherwise, destroy on timeout by default
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+ const cluster = require ( 'cluster' ) ;
6
+ const http = require ( 'http' ) ;
7
+ const net = require ( 'net' ) ;
8
+
9
+ if ( cluster . isMaster ) {
10
+ const worker = cluster . fork ( ) ;
11
+ const server = net . createServer ( {
12
+ pauseOnConnect : true
13
+ } , common . mustCall ( ( socket ) => {
14
+ worker . send ( 'socket' , socket ) ;
15
+ } ) ) ;
16
+
17
+ worker . on ( 'exit' , common . mustCall ( ( code , signal ) => {
18
+ assert . strictEqual ( code , 0 ) ;
19
+ server . close ( ) ;
20
+ } ) ) ;
21
+
22
+ server . listen ( 0 , common . mustCall ( ( ) => {
23
+ net . createConnection ( server . address ( ) . port ) ;
24
+ } ) ) ;
25
+ } else {
26
+ const server = http . createServer ( ) ;
27
+
28
+ server . setTimeout ( 100 , common . mustCall ( ( socket ) => {
29
+ socket . destroy ( ) ;
30
+ cluster . worker . kill ( ) ;
31
+ } ) ) ;
32
+
33
+ process . on ( 'message' , common . mustCall ( ( message , socket ) => {
34
+ server . emit ( 'connection' , socket ) ;
35
+ socket . resume ( ) ;
36
+ } ) ) ;
37
+ }
You can’t perform that action at this time.
0 commit comments