]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/fulltext/serv_fulltext.c
Added some more CtdlThreadCheckStop() calls to speed shutdown.
[citadel.git] / citadel / modules / fulltext / serv_fulltext.c
index 4737f66f07a7069a5f7e16b174c35cec0f23107f..4e8ea9b6b77550bd7803bc6c137ba5aa75db6167 100644 (file)
@@ -42,7 +42,7 @@
 #include "room_ops.h"
 #include "serv_fulltext.h"
 #include "ft_wordbreaker.h"
-
+#include "threads.h"
 
 #include "ctdl_module.h"
 
@@ -207,6 +207,9 @@ void ft_index_msg(long msgnum, void *userdata) {
  */
 void ft_index_room(struct ctdlroom *qrbuf, void *data)
 {
+       if (CtdlThreadCheckStop())
+               return;
+               
        getroom(&CC->room, qrbuf->QRname);
        CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, ft_index_msg, NULL);
 }
@@ -222,8 +225,6 @@ void do_fulltext_indexing(void) {
        time_t run_time = 0L;
        time_t end_time = 0L;
        
-       CT_PUSH();
-       
        /*
         * Don't do this if the site doesn't have it enabled.
         */
@@ -299,7 +300,7 @@ void do_fulltext_indexing(void) {
                        ft_index_message(ft_newmsgs[i], 1);
 
                        /* Check to see if we need to quit early */
-                       if (CtdlThreadCheckStop(CT)) {
+                       if (CtdlThreadCheckStop()) {
                                lprintf(CTDL_DEBUG, "Indexer quitting early\n");
                                ft_newhighest = ft_newmsgs[i];
                                break;
@@ -320,8 +321,12 @@ void do_fulltext_indexing(void) {
                ft_newmsgs = NULL;
        }
        end_time = time(NULL);
-       lprintf(CTDL_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
 
+       if (CtdlThreadCheckStop())
+               return;
+       
+       lprintf(CTDL_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
+               
        /* Save our place so we don't have to do this again */
        ft_flush_cache();
        begin_critical_section(S_CONTROL);
@@ -341,8 +346,6 @@ void do_fulltext_indexing(void) {
 void *indexer_thread(void *arg) {
        struct CitContext indexerCC;
 
-       CT_PUSH();
-       
        lprintf(CTDL_DEBUG, "indexer_thread() initializing\n");
 
        memset(&indexerCC, 0, sizeof(struct CitContext));
@@ -350,9 +353,7 @@ void *indexer_thread(void *arg) {
        indexerCC.cs_pid = 0;
        pthread_setspecific(MyConKey, (void *)&indexerCC );
 
-       cdb_allocate_tsd();
-
-       while (!CtdlThreadCheckStop(CT)) {
+       while (!CtdlThreadCheckStop()) {
                do_fulltext_indexing();
                CtdlThreadSleep(300);
        }
@@ -503,7 +504,7 @@ CTDL_MODULE_INIT(fulltext)
        }
        else
        {
-               CtdlThreadCreate("indexer", CTDLTHREAD_BIGSTACK, indexer_thread, NULL);
+               CtdlThreadCreate("Indexer", CTDLTHREAD_BIGSTACK, indexer_thread, NULL);
        }
        /* return our Subversion id for the Log */
        return "$Id$";