From 2ba3c10d6244d32a4196b59b4d46f069c7482795 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 18 Nov 2010 14:19:09 -0800 Subject: [PATCH] Only try to flush big buffers once --- lib/net.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/net.js b/lib/net.js index 62abffdaf53..90c44a04194 100644 --- a/lib/net.js +++ b/lib/net.js @@ -59,6 +59,8 @@ IOWatcher.prototype.ondrain = function () { if (this.socket) { var socket = this.socket; + socket._haveTriedFlush = false; + if (socket.writable || socket.readable) { require('timers').active(socket); } @@ -327,8 +329,9 @@ Stream.prototype.write = function (data /* encoding, fd, callback */) { this._onWritable(); // Insert writeWatcher into the dumpQueue require('timers').active(this); - if (queueSize > (64*1024)) { + if (queueSize > (64*1024) && !this._haveTriedFlush) { IOWatcher.flush(); + this._haveTriedFlush = true; } return queueSize < (64*1024);