]> code.citadel.org Git - citadel.git/blobdiff - citadel/server_main.c
* Applied a patch sent in by Wilfried Goesgens which allows the various
[citadel.git] / citadel / server_main.c
index 75c6c713752a4139f5aa8f8c5c4eb5ba6fbe98d5..c29caa7aa9d5cca74356e3be3ed41e20017d3c05 100644 (file)
@@ -183,7 +183,12 @@ int main(int argc, char **argv)
         * Bind the server to a Unix-domain socket.
         */
        CtdlRegisterServiceHook(0,
-                               "citadel.socket",
+#ifndef HAVE_RUN_DIR
+                                        "."
+#else
+                                        RUN_DIR
+#endif
+                               "/citadel.socket",
                                citproto_begin_session,
                                do_command_loop,
                                do_async_loop);
@@ -234,18 +239,23 @@ int main(int argc, char **argv)
        /*
         * Now create a bunch of worker threads.
         */
-       lprintf(CTDL_DEBUG, "Starting %d worker threads\n", config.c_min_workers-1);
+       lprintf(CTDL_DEBUG, "Starting %d worker threads\n",
+               config.c_min_workers-1);
        begin_critical_section(S_WORKER_LIST);
        for (i=0; i<(config.c_min_workers-1); ++i) {
                create_worker();
        }
        end_critical_section(S_WORKER_LIST);
 
-       /* Now this thread can become a worker as well. */
-       worker_thread(NULL);
+       /* Create the indexer thread. */
+       create_maintenance_threads();
 
-       /* Server is exiting. Wait for workers to shutdown. */
-       lprintf(CTDL_INFO, "Server is shutting down.\n");
+       /* This thread is now useless.  It can't be turned into a worker
+        * thread because its stack is too small, but it can't be killed
+        * either because the whole server process would exit.  So we just
+        * join to the first worker thread and exit when it exits.
+        */
+       pthread_join(worker_list->tid, NULL);
        master_cleanup(0);
        return(0);
 }