X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_fulltext.c;h=61e2085bda2cebaaeb13f02aa3692f44de970b65;hb=acfcc89045bbdc80ae7614ca3ee38303ae98f08b;hp=d2384ab4f4f97521cb6f127e231ee7d74dcd216a;hpb=93b3f964e265805a6173f2828465e958dbbe7ac0;p=citadel.git diff --git a/citadel/serv_fulltext.c b/citadel/serv_fulltext.c index d2384ab4f..61e2085bd 100644 --- a/citadel/serv_fulltext.c +++ b/citadel/serv_fulltext.c @@ -253,6 +253,14 @@ void do_fulltext_indexing(void) { last_progress = time(NULL); } ft_index_message(ft_newmsgs[i], 1); + + /* Check to see if we need to quit early */ + if (time_to_die) { + lprintf(CTDL_DEBUG, "Indexer quitting early\n"); + ft_newhighest = ft_newmsgs[i]; + break; + } + } free(ft_newmsgs); @@ -271,6 +279,31 @@ void do_fulltext_indexing(void) { return; } +/* + * Main loop for the indexer thread. + */ +void *indexer_thread(void *arg) { + struct CitContext indexerCC; + + lprintf(CTDL_DEBUG, "indexer_thread() initializing\n"); + + memset(&indexerCC, 0, sizeof(struct CitContext)); + indexerCC.internal_pgm = 1; + indexerCC.cs_pid = 0; + pthread_setspecific(MyConKey, (void *)&indexerCC ); + + cdb_allocate_tsd(); + + while (!time_to_die) { + do_fulltext_indexing(); + sleep(1); + } + + lprintf(CTDL_DEBUG, "indexer_thread() exiting\n"); + pthread_exit(NULL); +} + + /* * API call to perform searches. @@ -378,7 +411,6 @@ void cmd_srch(char *argbuf) { char *serv_fulltext_init(void) { - CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER); CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search"); return "$Id$"; }