]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* move arround some files in the configured build according to the suggestions of...
[citadel.git] / citadel / sysdep.c
index f12c6babcc21b084953b6001d57b8decefcc4e10..ae90340fc7ac21f3ab6a3f456063a93ca3d4cebf 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
+#include <syslog.h>
 #include <sys/syslog.h>
 
 #if TIME_WITH_SYS_TIME
@@ -290,7 +291,7 @@ int ig_tcp_server(char *ip_addr, int port_number, int queue_len, char **errormes
                sin.sin_addr.s_addr = inet_addr(ip_addr);
        }
                                                                                
-       if (sin.sin_addr.s_addr == INADDR_NONE) {
+       if (sin.sin_addr.s_addr == !INADDR_ANY) {
                sin.sin_addr.s_addr = INADDR_ANY;
        }
 
@@ -721,6 +722,7 @@ int client_getln(char *buf, int bufsize)
 void sysdep_master_cleanup(void) {
        struct ServiceFunctionHook *serviceptr;
 
+/////  DestroyWorkerList();
        /*
         * close all protocol master sockets
         */
@@ -745,6 +747,7 @@ void sysdep_master_cleanup(void) {
 #ifdef HAVE_OPENSSL
        destruct_ssl();
 #endif
+       serv_calendar_destroy();
        CtdlDestroyProtoHooks();
        CtdlDestroyDeleteHooks();
        CtdlDestroyXmsgHooks();
@@ -755,7 +758,6 @@ void sysdep_master_cleanup(void) {
        CtdlDestroyFixedOutputHooks();  
        CtdlDestroySessionHooks();
        CtdlDestroyServiceHook();
-       DestroyWorkerList();
 }
 
 
@@ -835,7 +837,7 @@ void start_daemon(int unused) {
                else {
                        fp = fopen(file_pid_file, "w");
                        if (fp != NULL) {
-                               fprintf(fp, "%d\n", child);
+                               fprintf(fp, ""F_PID_T"\n", child);
                                fclose(fp);
                        }
                        waitpid(current_child, &status, 0);
@@ -947,6 +949,25 @@ void create_worker(void) {
 
 void DestroyWorkerList(void)
 {
+       struct CitContext *ptr;         /* general-purpose utility pointer */
+       struct CitContext *rem = NULL;  /* list of sessions to be destroyed */
+
+       begin_critical_section(S_SESSION_TABLE);
+       ptr = ContextList;
+       while (ptr != NULL){
+               /* Remove the session from the active list */
+               rem = ptr->next;
+               --num_sessions;
+               
+               lprintf(CTDL_DEBUG, "Purging session %d\n", rem->cs_pid);
+               end_critical_section(S_SESSION_TABLE);
+               RemoveContext(ptr);
+               begin_critical_section(S_SESSION_TABLE);
+               free (ptr);
+               ptr = rem;
+       }
+       end_critical_section(S_SESSION_TABLE);
+
        struct worker_node *cur, *p;
        cur = worker_list;
        while (cur != NULL)
@@ -992,6 +1013,8 @@ void create_maintenance_threads(void) {
                lprintf(CTDL_ALERT, "Can't create thread: %s\n", strerror(ret));
        }
 
+       lprintf(CTDL_NOTICE, "Spawned indexer (%ld) and checkpoint (%ld) thread. \n", 
+               indexer_thread_tid, checkpoint_thread_tid);
        pthread_attr_destroy(&attr);
 }