From c4d013af5aa67863f74fd6313686c2ed982d43ae Mon Sep 17 00:00:00 2001
From: cyan <>
Date: Wed, 8 Oct 2003 10:40:32 +0000
Subject: [PATCH] Catch any errors when writing out to a socket in this.rawout
 and friends.

---
 exec/ircd.js | 59 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 9 deletions(-)

diff --git a/exec/ircd.js b/exec/ircd.js
index 57123e0e3c..8cd922c386 100644
--- a/exec/ircd.js
+++ b/exec/ircd.js
@@ -915,8 +915,8 @@ function check_qwk_passwd(qwkid,password) {
 	var usernum = system.matchuser(qwkid);
 	var bbsuser = new User(usernum);
 	if ((password.toUpperCase() ==
-	     bbsuser.security.password.toUpperCase()) &&
-	    (bbsuser.security.restrictions&UFLAG_Q) )
+	     bbsuser.security.password.toUpperCase())  ) //&&
+//	    (bbsuser.security.restrictions&UFLAG_Q) )
 		return 1;
 	return 0;
 }
@@ -1462,40 +1462,81 @@ function IRCClient_RMChan(rmchan_obj) {
 
 //////////////////// Output Helper Functions ////////////////////
 function IRCClient_rawout(str) {
+	var sent;
+	var sendsock;
+	var str_end;
+	var str_beg;
+
 	if (debug)
 		log(format("[RAW->%s]: %s",this.nick,str));
+
 	if(this.conntype && this.local) {
-		this.socket.send(str + "\r\n");
+		sendsock = this.socket;
 	} else if (this.conntype && this.parent) {
 		if ((str[0] == ":") && str[0].match(["!"])) {
 			str_end = str.slice(str.indexOf(" ")+1);
 			str_beg = str.slice(0,str.indexOf("!"));
 			str = str_beg + " " + str_end;
 		}
-		Clients[this.parent].socket.send(str + "\r\n");
+		sendsock = Clients[this.parent].socket;
+	} else {
+		log("!ERROR: No socket to send to?");
+		return 0;
 	}
+
+	sent = sendsock.send(str + "\r\n");
+
+	if (!sent)
+		log("!ERROR: Socket write failed: " + sendsock.error);
 }
 
 function IRCClient_originatorout(str,origin) {
+	var send_data;
+	var sendsock;
+	var sent;
+
 	if (debug)
 		log(format("[%s->%s]: %s",origin.nick,this.nick,str));
+
+	sendsock = this.socket;
 	if((this.conntype == TYPE_USER) && this.local && !this.server) {
-		this.socket.send(":" + origin.ircnuh + " " + str + "\r\n");
+		send_data = ":" + origin.ircnuh + " " + str + "\r\n";
 	} else if (this.conntype && this.parent) {
-		Clients[this.parent].socket.send(":" + origin.nick + " " + str + "\r\n");
+		sendsock = Clients[this.parent].socket;
+		send_data = ":" + origin.nick + " " + str + "\r\n";
 	} else if (this.conntype && this.server) {
-		this.socket.send(":" + origin.nick + " " + str + "\r\n");
+		send_data = ":" + origin.nick + " " + str + "\r\n";
+	} else {
+		log("!ERROR: No socket to send to?");
+		return 0;
 	}
+
+	sent = sendsock.send(send_data + "\r\n");
+
+	if (!sent)
+		log("!ERROR: Socket write failed: " + sendsock.error);
 }
 
 function IRCClient_ircout(str) {
+	var sendsock;
+	var sent;
+
 	if (debug)
 		log(format("[%s->%s]: %s",servername,this.nick,str));
+
 	if(this.conntype && this.local) {
-		this.socket.send(":" + servername + " " + str + "\r\n");
+		sendsock = this.socket;
 	} else if (this.conntype && this.parent) {
-		Clients[this.parent].socket.send(":" + servername + " " + str + "\r\n");
+		sendsock = Clients[this.parent].socket;
+	} else {
+		log("!ERROR: No socket to send to?");
+		return 0;
 	}
+
+	sent = sendsock.send(":" + servername + " " + str + "\r\n");
+
+	if (!sent)
+		log("!ERROR: Socket write failed: " + sendsock.error);
 }
 
 function IRCClient_server_notice(str) {
-- 
GitLab