]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/sysdep.c
master_cleanup() is now the global shutdown/exit function
[citadel.git] / citadel / server / sysdep.c
index 668b50bd023d4e8c1a402f2f273c7de9240bcd79..f6e34a3dd00b766ceef337fcc540c5a9f33c5bfd 100644 (file)
@@ -1,12 +1,10 @@
-// Citadel "system dependent" stuff.
-//
-// Here's where we (hopefully) have most parts of the Citadel server that
-// might need tweaking when run on different operating system variants.
+// This started as a portability layer, but then everything got more standard.
+// Most of it handles network communication.
 //
 // Copyright (c) 1987-2023 by the citadel.org team
 //
-// This program is open source software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 3.
+// This program is open source software.  Use, duplication, or disclosure
+// is subject to the terms of the GNU General Public License, version 3.
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -121,6 +119,7 @@ int ctdl_tcp_server(char *ip_addr, int port_number, int queue_len) {
        if (    (ip_addr == NULL)                                                       // any IPv6
                || (IsEmptyStr(ip_addr))
                || (!strcmp(ip_addr, "*"))
+               || (!strcmp(ip_addr, "::"))
        ) {
                ip_version = 6;
                sin6.sin6_addr = in6addr_any;
@@ -567,13 +566,6 @@ int client_getln(char *buf, int bufsize) {
 }
 
 
-// The system-dependent part of master_cleanup() - close the master socket.
-void sysdep_master_cleanup(void) {
-       context_cleanup();
-}
-
-
-
 pid_t current_child;
 void supervisor_process_shutdown(int signum) {
        kill(current_child, signum);
@@ -937,7 +929,7 @@ do_select:  force_purge = 0;
                begin_critical_section(S_SESSION_TABLE);
                for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
                        int checkfd = ptr->client_socket;
-                       if ((checkfd != -1) && (ptr->state == CON_IDLE) ){
+                       if ((checkfd != -1) && (ptr->state == CON_IDLE)){
                                if (FD_ISSET(checkfd, &readfds)) {
                                        ptr->input_waiting = 1;
                                        if (!bind_me) {
@@ -947,7 +939,8 @@ do_select:  force_purge = 0;
                                        else {
                                                ptr->state = CON_READY;
                                        }
-                               } else if ((ptr->is_async) && (ptr->async_waiting) && (ptr->h_async_function)) {
+                               }
+                               else if ((ptr->is_async) && (ptr->async_waiting) && (ptr->h_async_function)) {
                                        if (!bind_me) {
                                                bind_me = ptr;  // I choose you!
                                                bind_me->state = CON_EXECUTING;
@@ -1000,9 +993,9 @@ SKIP_SELECT:
 
                pthread_mutex_lock(&ThreadCountMutex);
                --active_workers;
-               if ((active_workers + CtdlGetConfigInt("c_min_workers") < num_workers) &&
-                   (num_workers > CtdlGetConfigInt("c_min_workers")))
-               {
+               if (    (active_workers + CtdlGetConfigInt("c_min_workers") < num_workers)
+                       && (num_workers > CtdlGetConfigInt("c_min_workers"))
+               {
                        num_workers--;
                        pthread_mutex_unlock(&ThreadCountMutex);
                        return (NULL);
@@ -1020,11 +1013,9 @@ SKIP_SELECT:
 
 // SyslogFacility()
 // Translate text facility name to syslog.h defined value.
-int SyslogFacility(char *name)
-{
+int SyslogFacility(char *name) {
        int i;
-       struct
-       {
+       struct {
                int facility;
                char *name;
        }   facTbl[] =