diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2014-01-29 02:48:10 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-01-29 02:49:03 +0400 |
commit | 9836a4eeda1e2d43aad0923f1f72b364792629bc (patch) | |
tree | f9a43115eaca3a49f83c910d20ea363bef3b2b29 /lib/net.js | |
parent | eaf76648a6ba05932465fdb2478a16ca4b6c17a6 (diff) | |
download | node-new-9836a4eeda1e2d43aad0923f1f72b364792629bc.tar.gz |
stream_wrap: use `uv_try_write` where possible
Use `uv_try_write` for string and buffer writes, thus avoiding to do
allocations and copying in some of the cases.
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/net.js b/lib/net.js index 800bae38cf..8e6dcbf7bf 100644 --- a/lib/net.js +++ b/lib/net.js @@ -626,7 +626,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) { return false; } - var req = { oncomplete: afterWrite }; + var req = { oncomplete: afterWrite, async: false }; var err; if (writev) { @@ -660,10 +660,10 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) { // If it was entirely flushed, we can write some more right now. // However, if more is left in the queue, then wait until that clears. - if (this._handle.writeQueueSize === 0) - cb(); - else + if (req.async && this._handle.writeQueueSize != 0) req.cb = cb; + else + cb(); }; |