From 3619e5935e8363674e07e52c5115ebe3cea46b2f Mon Sep 17 00:00:00 2001 From: Darren Date: Wed, 24 Sep 2014 00:31:00 +0100 Subject: [PATCH] Only writing to IRCd socket if it exists --- server/irc/connection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/irc/connection.js b/server/irc/connection.js index 0c6f70c..9584ffa 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -374,7 +374,7 @@ IrcConnection.prototype.write = function (data, force, force_complete_fn) { var encoded_buffer = iconv.encode(data + '\r\n', this.encoding); if (force) { - this.socket.write(encoded_buffer, force_complete_fn); + this.socket && this.socket.write(encoded_buffer, force_complete_fn); return; } @@ -405,7 +405,7 @@ IrcConnection.prototype.flushWriteBuffer = function () { // Disabled write buffer? Send everything we have if (!this.write_buffer_lines_second) { this.write_buffer.forEach(function(buffer) { - this.socket.write(buffer); + this.socket && this.socket.write(buffer); this.write_buffer = null; }); @@ -421,7 +421,7 @@ IrcConnection.prototype.flushWriteBuffer = function () { return; } - this.socket.write(this.write_buffer[0]); + this.socket && this.socket.write(this.write_buffer[0]); this.write_buffer = this.write_buffer.slice(1); // Call this function again at some point if we still have data to write -- 2.25.1