diff options
author | Kevin van Zonneveld <kevin@vanzonneveld.net> | 2009-08-21 17:54:10 +0200 |
---|---|---|
committer | Ryan <ry@tinyclouds.org> | 2009-08-21 17:54:10 +0200 |
commit | 8489bdbaeb07b18a736a438719adc8837c1908a0 (patch) | |
tree | b0bfaf092923bf76f09b7278dc11f9fd0089a44f /src | |
parent | ed3602dddcd0e7ddaedd8962252479ded992d95b (diff) | |
download | nodejs-8489bdbaeb07b18a736a438719adc8837c1908a0.tar.gz nodejs-8489bdbaeb07b18a736a438719adc8837c1908a0.tar.bz2 nodejs-8489bdbaeb07b18a736a438719adc8837c1908a0.zip |
Buggy connections could crash node.js. Now check connection before sending data every time
http://groups.google.com/group/nodejs/browse_thread/thread/16abfa87c32408f3
We have our node.js server monitored by monit, however it seems monit is pretty
agressive / quick about closing its connection and thus we've gotten into a
loop of errors like this:
at #<a ServerResponse>.flush
at #<a ServerResponse>.sendBody
at [object Object].json
at [object Object].[anonymous]
at [object Object].[anonymous]
at [object Object].[anonymous]
http.js:353: Socket is not open for writing
connection.send(out, out.encoding);
^
Below is a patch that basically cause flushMessageQueue to check the connection
state for each item in the queue rather than just a single time in the
beginning.
Diffstat (limited to 'src')
-rw-r--r-- | src/http.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/http.js b/src/http.js index b59896a20..abf489095 100644 --- a/src/http.js +++ b/src/http.js @@ -341,14 +341,13 @@ function createIncomingMessageStream (connection, incoming_listener) { /* Returns true if the message queue is finished and the connection * should be closed. */ function flushMessageQueue (connection, queue) { - if (connection.readyState !== "open" && connection.readyState !== "writeOnly") { - return false; - } - while (queue[0]) { var message = queue[0]; while (message.output.length > 0) { + if (connection.readyState !== "open" && connection.readyState !== "writeOnly") { + return false; + } var out = message.output.shift(); connection.send(out, out.encoding); } |