summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-10-15 03:27:25 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2011-10-15 03:34:09 +0200
commit0b92fa0e9326a395e3b5368091e2008be2ba8ae3 (patch)
treea558d1f8014ad199a7b9805f41fd21e5946d3595 /lib
parent6df574b744f376b18a6697595717c9fd6abd59e9 (diff)
downloadnode-new-0b92fa0e9326a395e3b5368091e2008be2ba8ae3.tar.gz
net: fix connect queue bugs
This commit fixes two bugs in the handling of write requests when the connect() call is still in progress. 1. The deferred write request's size was counted twice towards `.bytesWritten`. 2. The callback was not called. After connecting, `Socket.write()` was called with three arguments (data, encoding, cb) but it ignored the third argument. Coincidentally fixes test/simple/test-net-connect-buffer.js.
Diffstat (limited to 'lib')
-rw-r--r--lib/net.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/net.js b/lib/net.js
index cb8e25ed60..4467654802 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -399,6 +399,12 @@ Socket.prototype.write = function(data, arg1, arg2) {
return false;
}
+ return this._write(data, encoding, cb);
+};
+
+
+Socket.prototype._write = function(data, encoding, cb) {
+ // `encoding` is unused right now, `data` is always a buffer.
var writeReq = this._handle.write(data);
if (!writeReq) {
@@ -557,7 +563,7 @@ function afterConnect(status, handle, req) {
if (self._connectQueue) {
debug('Drain the connect queue');
for (var i = 0; i < self._connectQueue.length; i++) {
- self.write.apply(self, self._connectQueue[i]);
+ self._write.apply(self, self._connectQueue[i]);
}
self._connectQueueCleanUp();
}