From 88f9b2248bfb016514e340ee5eb81df7337fcc94 Mon Sep 17 00:00:00 2001 From: Test_User Date: Sat, 15 Jun 2024 14:16:50 -0400 Subject: Improvements and the start of reloadable modules --- server_network.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'server_network.c') diff --git a/server_network.c b/server_network.c index 1afd370..bf9e442 100644 --- a/server_network.c +++ b/server_network.c @@ -95,15 +95,17 @@ int start_server_network_threads(size_t net) { pthread_t trash; // Not actually used, so discard struct server_network_info *type; #ifdef USE_INSPIRCD2_PROTOCOL - type = malloc(sizeof(*type)); - if (!type) - return 1; - type->net_type = net; - type->protocol = INSPIRCD2_PROTOCOL; - type->is_incoming = 1; - if (pthread_create(&trash, &pthread_attr, server_accept_thread, type) != 0) { - free(type); - return 1; + if (SERVER_INCOMING[net][INSPIRCD2_PROTOCOL]) { + type = malloc(sizeof(*type)); + if (!type) + return 1; + type->net_type = net; + type->protocol = INSPIRCD2_PROTOCOL; + type->is_incoming = 1; + if (pthread_create(&trash, &pthread_attr, server_accept_thread, type) != 0) { + free(type); + return 1; + } } #endif return 0; @@ -118,19 +120,6 @@ void * server_accept_thread(void *type) { protocol = t->protocol; } - // Check if there is actually an incoming server connection configured using this net+protocol, and if not just return from this thread; some excess may have been spawned - { - char found = 0; - for (size_t i = 0; i < SERVER_CONFIG_LEN; i++) { - if (SERVER_CONFIG[i].protocol == protocol && !(SERVER_CONFIG[i].autoconnect)) { // TODO: Don't make autoconnect conflict with incoming connections - found = 1; - break; - } - } - if (!found) - return 0; - } - int listen_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listen_fd < 0) return 0; -- cgit v1.2.3