From 99e8c77caf4a718768e80e6a46c6f336a67587a4 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Mon, 24 Jul 2023 18:28:41 -0700
Subject: [PATCH] Revert "Revert "Apply socket options from sockopts.ini to
 sockets created by ListeningSocket()""

This reverts commit 7ff687ff15f690410daa0bdbe2ecc468ea1b4a41.

We're already passing a sock_init callback (ls_cb) which is supposed to set
the socket options (call set_socket_options), so this change shouldn't be
necessary and reportedly caused more issues binding ircd sockets when running
ircd.js via jsexec (though I didn't see this myself).
---
 src/sbbs3/js_socket.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/sbbs3/js_socket.c b/src/sbbs3/js_socket.c
index aa657371f6..fb6eff8ac2 100644
--- a/src/sbbs3/js_socket.c
+++ b/src/sbbs3/js_socket.c
@@ -3359,6 +3359,17 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
 		}
 	}
 
+	for (i = 0; (jsuint)i < set->sock_count; ++i) {
+		char error[256] = "";
+		if (set_socket_options(scfg, set->socks[i].sock, protocol, error, sizeof(error)) != 0) {
+			JS_ReportError(cx, "Error (%s) setting socket options (for %s) on socket %d"
+				,error, protocol, set->socks[i].sock);
+			free(protocol);
+			free(set);
+			return JS_FALSE;
+		}
+	}
+
 	obj=JS_NewObject(cx, &js_socket_class, NULL, NULL);
 	JS_SET_RVAL(cx, arglist, OBJECT_TO_JSVAL(obj));
 
-- 
GitLab