Initialize TSD key earlier in the startup process. Newer Linux/Linux distributions...
[citadel.git] / citadel / sysdep.c
index ec320eeef2a873043a0734394424febf74a14214..c547f9772be4cff4c5fee27c84291bfb8d93817a 100644 (file)
@@ -4,7 +4,7 @@
  * Here's where we (hopefully) have most parts of the Citadel server that
  * might need tweaking when run on different operating system variants.
  *
- * Copyright (c) 1987-2017 by the citadel.org team
+ * Copyright (c) 1987-2019 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.
@@ -86,14 +86,14 @@ void init_sysdep(void) {
        init_ssl();
 #endif
 
-       /*
-        * Set up a place to put thread-specific data.
-        * We only need a single pointer per thread - it points to the
-        * CitContext structure (in the ContextList linked list) of the
-        * session to which the calling thread is currently bound.
-        */
-       if (pthread_key_create(&MyConKey, NULL) != 0) {
+       if (pthread_key_create(&ThreadKey, NULL) != 0) {                        // TSD for threads
+               syslog(LOG_ERR, "pthread_key_create() : %m");
+               abort();
+       }
+       
+       if (pthread_key_create(&MyConKey, NULL) != 0) {                         // TSD for sessions
                syslog(LOG_CRIT, "sysdep: can't create TSD key: %m");
+               abort();
        }
 
        /*
@@ -922,7 +922,6 @@ void sysdep_master_cleanup(void) {
        CtdlDestroyProtoHooks();
        CtdlDestroyDeleteHooks();
        CtdlDestroyXmsgHooks();
-       CtdlDestroyNetprocHooks();
        CtdlDestroyUserHooks();
        CtdlDestroyMessageHook();
        CtdlDestroyCleanupHooks();
@@ -1110,12 +1109,12 @@ void HuntBadSession(void)
                        {
                                /* Gotcha! */
                                syslog(LOG_ERR,
-                                      "sysdep: killing session CC[%d] bad FD: [%d:%d] User[%s] Host[%s:%s]",
-                                      ptr->cs_pid,
-                                      ptr->client_socket,
-                                      ptr->is_local_socket,
-                                      ptr->curr_user,
-                                      ptr->cs_host,ptr->cs_addr
+                                      "sysdep: killing session CC[%d] bad FD: [%d] User[%s] Host[%s:%s]",
+                                       ptr->cs_pid,
+                                       ptr->client_socket,
+                                       ptr->curr_user,
+                                       ptr->cs_host,
+                                       ptr->cs_addr
                                );
                                ptr->kill_me = 1;
                                ptr->client_socket = -1;
@@ -1293,9 +1292,9 @@ do_select:        force_purge = 0;
                                        con->h_greeting_function = serviceptr->h_greeting_function;
                                        con->ServiceName = serviceptr->ServiceName;
                                        
-                                       /* Determine whether it's a local socket */
+                                       /* Connections on a local client are always from the same host */
                                        if (serviceptr->sockpath != NULL) {
-                                               con->is_local_socket = 1;
+                                               con->is_local_client = 1;
                                        }
        
                                        /* Set the SO_REUSEADDR socket option */