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.
This commit is contained in:
Ben Noordhuis 2011-10-15 03:27:25 +02:00
Родитель 6df574b744
Коммит 0b92fa0e93
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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();
}