summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-01-07 18:07:37 -0800
committerisaacs <i@izs.me>2013-01-10 13:50:05 -0800
commit840401c024a31e35515e76155693131f6de0ea86 (patch)
treeba75b8764c7fa86484ffe793de8b612c511f6e6a
parentb43e544140ccf68580c02e71c56d19b82e1e1d32 (diff)
downloadnode-new-840401c024a31e35515e76155693131f6de0ea86.tar.gz
net: Use readable.push() instead of private methods
-rw-r--r--lib/net.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/net.js b/lib/net.js
index 5176b23464..89cb0d7275 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -472,10 +472,11 @@ function onread(buffer, offset, length) {
self.bytesRead += length;
// Optimization: emit the original buffer with end points
+ var ret = true;
if (self.ondata) self.ondata(buffer, offset, end);
- else self._readableState.onread(null, buffer.slice(offset, end));
+ else ret = self.push(buffer.slice(offset, end));
- if (handle.reading && !self._readableState.reading) {
+ if (handle.reading && !ret) {
handle.reading = false;
debug('readStop');
var r = handle.readStop();
@@ -492,7 +493,7 @@ function onread(buffer, offset, length) {
if (self.onend) self.once('end', self.onend);
// send a null to the _read cb to signal the end of data.
- self._readableState.onread(null, null);
+ self.push(null);
// internal end event so that we know that the actual socket
// is no longer readable, and we can start the shutdown