Created
December 15, 2012 22:33
-
-
Save isaacs/4299932 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/net.js b/lib/net.js | |
index d0a2c5a..42c2109 100644 | |
--- a/lib/net.js | |
+++ b/lib/net.js | |
@@ -595,9 +595,12 @@ Socket.prototype._write = function(dataEncoding, cb) { | |
return this._destroy(errnoException(errno, 'write'), cb); | |
writeReq.oncomplete = afterWrite; | |
- writeReq.cb = cb; | |
- | |
this._bytesDispatched += writeReq.bytes; | |
+ | |
+ if (this._handle.writeQueueSize === 0) | |
+ cb(); | |
+ else | |
+ writeReq.cb = cb; | |
}; | |
@@ -640,7 +643,8 @@ function afterWrite(status, handle, req) { | |
if (self !== process.stderr && self !== process.stdout) | |
debug('afterWrite call cb'); | |
- req.cb.call(self); | |
+ if (req.cb) | |
+ req.cb.call(self); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment