Skip to content

Commit

Permalink
net: ensure WriteWrap references the handle
Browse files Browse the repository at this point in the history
`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.

Fix: nodejs#1580
  • Loading branch information
indutny committed May 2, 2015
1 parent ea5195c commit 146bea1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
}

var req = new WriteWrap();
req.handle = this._handle;
req.oncomplete = afterWrite;
req.async = false;
var err;
Expand Down

0 comments on commit 146bea1

Please sign in to comment.