From 3ee73c6c5efbe30684189e26ad3c73b1d3890fde Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 3 Apr 2020 21:14:00 +0000
Subject: [PATCH] Actually decrement the class active connection count on
 close(). Also, log it when it's changed.

---
 exec/ircd.js             | 1 +
 exec/load/ircd_server.js | 6 ++++--
 exec/load/ircd_unreg.js  | 6 ++++--
 exec/load/ircd_user.js   | 6 ++++--
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/exec/ircd.js b/exec/ircd.js
index 66c91dd077..87a0a8c6f1 100644
--- a/exec/ircd.js
+++ b/exec/ircd.js
@@ -672,6 +672,7 @@ function connect_to_server(this_cline,the_port) {
 		Unregistered[new_id].outgoing = true; /* Outgoing Connection */
 		Unregistered[new_id].ircclass = this_cline.ircclass;
 		YLines[this_cline.ircclass].active++;
+		log(LOG_DEBUG, "Class "+this_cline.ircclass+" up to "+YLines[this_cline.ircclass].active+" active out of "+YLines[this_cline.ircclass].maxlinks);
 	}
 	else {
 		umode_notice(USERMODE_ROUTING,"Routing",
diff --git a/exec/load/ircd_server.js b/exec/load/ircd_server.js
index aac56bb2fc..df2057afbf 100644
--- a/exec/load/ircd_server.js
+++ b/exec/load/ircd_server.js
@@ -1215,8 +1215,10 @@ function Server_Quit(str,suppress_bcast,is_netsplit,origin) {
 		if (this.socket!=undefined) {
 			this.socket.close();
 			if (this.outgoing) {
-				if (YLines[this.ircclass].active > 0)
-					YLines[this.ircclass].active;
+				if (YLines[this.ircclass].active > 0) {
+					YLines[this.ircclass].active--;
+					log(LOG_DEBUG, "Class "+this_cline.ircclass+" down to "+YLines[this_cline.ircclass].active+" active out of "+YLines[this_cline.ircclass].maxlinks);
+				}
 				else
 					log(LOG_ERROR, format("Class %d YLine going negative", this.ircclass));
 			}
diff --git a/exec/load/ircd_unreg.js b/exec/load/ircd_unreg.js
index 4e1347faa2..234919a161 100644
--- a/exec/load/ircd_unreg.js
+++ b/exec/load/ircd_unreg.js
@@ -310,8 +310,10 @@ function Unregistered_Quit(msg) {
 		log(LOG_INFO, "Unregistered_Quit(\""+msg+"\")");
 	this.socket.close();
 	if (this.outgoing) {
-		if (YLines[this.ircclass].active > 0)
-			YLines[this.ircclass].active;
+		if (YLines[this.ircclass].active > 0) {
+			YLines[this.ircclass].active--;
+			log(LOG_DEBUG, "Class "+this_cline.ircclass+" down to "+YLines[this_cline.ircclass].active+" active out of "+YLines[this_cline.ircclass].maxlinks);
+		}
 		else
 			log(LOG_ERROR, format("Class %d YLine going negative", this.ircclass));
 	}
diff --git a/exec/load/ircd_user.js b/exec/load/ircd_user.js
index 6cc6215d6d..43d6ae774d 100644
--- a/exec/load/ircd_user.js
+++ b/exec/load/ircd_user.js
@@ -1552,8 +1552,10 @@ function User_Quit(str,suppress_bcast,is_netsplit,origin) {
 			this.socket.close();
 			if (this.outgoing) {
 				log(LOG_ERROR, "Outgoing USER connection detected!");
-				if (YLines[this.ircclass].active > 0)
-					YLines[this.ircclass].active;
+				if (YLines[this.ircclass].active > 0) {
+					YLines[this.ircclass].active--;
+					log(LOG_DEBUG, "Class "+this_cline.ircclass+" down to "+YLines[this_cline.ircclass].active+" active out of "+YLines[this_cline.ircclass].maxlinks);
+				}
 				else
 					log(LOG_ERROR, format("Class %d YLine going negative", this.ircclass));
 			}
-- 
GitLab