Skip to content

Commit 26760a9

Browse files
indutnyFishrock123
authored andcommitted
net: ensure Write/ShutdownWrap references handle
`StreamBase::AfterWrite` is passing handle as an argument to the `afterWrite` function in net.js. Thus GC should not collect the handle and the request separately and assume that they are tied together. With this commit - request will always outlive the StreamBase instance, helping us survive the GC pass. Same applies to the ShutdownWrap instances, they should never be collected after the StreamBase instance. Fix: nodejs#1580 PR-URL: nodejs#1590 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 908643d commit 26760a9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/net.js

+2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ function onSocketFinish() {
201201

202202
var req = new ShutdownWrap();
203203
req.oncomplete = afterShutdown;
204+
req.handle = this._handle;
204205
var err = this._handle.shutdown(req);
205206

206207
if (err)
@@ -627,6 +628,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
627628
}
628629

629630
var req = new WriteWrap();
631+
req.handle = this._handle;
630632
req.oncomplete = afterWrite;
631633
req.async = false;
632634
var err;

0 commit comments

Comments
 (0)