summaryrefslogtreecommitdiff
path: root/lib/net.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-08-09 22:35:54 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-08-09 08:16:58 +0200
commitf9b7714b4b3f04cba10c4d8b32dad48a68988799 (patch)
tree23c8183f7ca55214e651ff252ef50abfc80bced4 /lib/net.js
parentf548433195ba08e77ba93640382f474c17a13ecf (diff)
downloadnode-new-f9b7714b4b3f04cba10c4d8b32dad48a68988799.tar.gz
src: don't call v8::Object::SetHiddenValue()
Don't use v8::Object::SetHiddenValue() to keep a reference alive to the buffer, we can just as easily do that from JS land and it's a lot faster to boot. Because the buffer is now a visible property of the write request object, it's essential that we do *not* log it - we'd be effectively serializing the whole buffer to a pretty-printed string.
Diffstat (limited to 'lib/net.js')
-rw-r--r--lib/net.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/net.js b/lib/net.js
index 6748f0d2de..bac7e47ece 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -640,7 +640,13 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
// Retain chunks
if (err === 0) req._chunks = chunks;
} else {
- var enc = util.isBuffer(data) ? 'buffer' : encoding;
+ var enc;
+ if (util.isBuffer(data)) {
+ req.buffer = data; // Keep reference alive.
+ enc = 'buffer';
+ } else {
+ enc = encoding;
+ }
err = createWriteReq(req, this._handle, data, enc);
}
@@ -743,7 +749,7 @@ function afterWrite(status, handle, req) {
var self = handle.owner;
var state = self._writableState;
if (self !== process.stderr && self !== process.stdout)
- debug('afterWrite', status, req);
+ debug('afterWrite', status);
// callback may come after call to destroy.
if (self.destroyed) {