test: fix racey-ness in tls-inception
authorFedor Indutny <fedor@indutny.com>
Tue, 3 Mar 2015 09:10:28 +0000 (04:10 -0500)
committerFedor Indutny <fedor@indutny.com>
Tue, 3 Mar 2015 21:07:37 +0000 (16:07 -0500)
Fix test failure on FreeBSD and SmartOS, which happens due to a bad
timing:

    events.js:141
          throw er; // Unhandled 'error' event
                ^
    Error: read ECONNRESET
        at exports._errnoException (util.js:734:11)
        at TLSWrap.onread (net.js:538:26)

The outer `net.conncet()` socket stays alive after the inner socket is
gone. This happens because `.pipe()`'s implementation does not `destroy`
the source side when the destination has emitted `close`.

Fix: https://github.com/iojs/io.js/issues/1012
PR-URL: https://github.com/iojs/io.js/pull/1040
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
test/parallel/test-tls-inception.js

index 76c747a..83b12a6 100644 (file)
@@ -28,6 +28,10 @@ a = tls.createServer(options, function (socket) {
   var dest = net.connect(options);
   dest.pipe(socket);
   socket.pipe(dest);
+
+  dest.on('close', function() {
+    socket.destroy();
+  });
 });
 
 // the "target" server