diff --git a/lib/dgram.js b/lib/dgram.js index 502537f796b..d623d89f784 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -301,7 +301,7 @@ Socket.prototype.send = function(buffer, self.emit('error', ex); } else if (self._handle) { - var req = {}; + var req = { buffer: buffer }; // Keep reference alive. if (callback) { req.callback = callback; req.oncomplete = afterSend; diff --git a/lib/net.js b/lib/net.js index 6748f0d2dea..bac7e47ece8 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) { diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 538c3db5cb2..0a3ba2cef65 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -49,7 +49,6 @@ using v8::Undefined; using v8::Value; -static Cached buffer_sym; static Cached bytes_sym; static Cached write_queue_size_sym; static Cached onread_sym; @@ -63,7 +62,6 @@ void StreamWrap::Initialize(Handle target) { initialized = true; HandleScope scope(node_isolate); - buffer_sym = FIXED_ONE_BYTE_STRING(node_isolate, "buffer"); bytes_sym = FIXED_ONE_BYTE_STRING(node_isolate, "bytes"); write_queue_size_sym = FIXED_ONE_BYTE_STRING(node_isolate, "writeQueueSize"); onread_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onread"); @@ -215,8 +213,6 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo& args) { char* storage = new char[sizeof(WriteWrap)]; WriteWrap* req_wrap = new(storage) WriteWrap(req_wrap_obj, wrap); - req_wrap_obj->SetHiddenValue(buffer_sym, buf_obj); - uv_buf_t buf; WriteBuffer(buf_obj, &buf); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 345cf58421f..c052224cf44 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -57,7 +57,6 @@ class SendWrap : public ReqWrap { static Persistent constructor; -static Cached buffer_sym; static Cached oncomplete_sym; static Cached onmessage_sym; @@ -87,7 +86,6 @@ UDPWrap::~UDPWrap() { void UDPWrap::Initialize(Handle target) { HandleScope scope(node_isolate); - buffer_sym = FIXED_ONE_BYTE_STRING(node_isolate, "buffer"); oncomplete_sym = FIXED_ONE_BYTE_STRING(node_isolate, "oncomplete"); onmessage_sym = FIXED_ONE_BYTE_STRING(node_isolate, "onmessage"); @@ -261,7 +259,6 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { assert(length <= Buffer::Length(buffer_obj) - offset); SendWrap* req_wrap = new SendWrap(req_wrap_obj, have_callback); - req_wrap->object()->SetHiddenValue(buffer_sym, buffer_obj); uv_buf_t buf = uv_buf_init(Buffer::Data(buffer_obj) + offset, length);