#include <sys/wait.h>
#include <string.h>
#include <limits.h>
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "msgbase.h"
#include "control.h"
#include "room_ops.h"
-#include "tools.h"
#include "serv_fulltext.h"
#include "ft_wordbreaker.h"
-
+#include "threads.h"
#include "ctdl_module.h"
*/
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);
}
* Make sure we don't run the indexer too frequently.
* FIXME move the setting into config
*/
+/*
+ * The thread sleeps for 300 seconds so we don't need this here any more
+
if ( (time(NULL) - last_index) < 300L) {
return;
}
+*/
/*
* Check to see whether the fulltext index is up to date; if there
ft_index_message(ft_newmsgs[i], 1);
/* Check to see if we need to quit early */
- if (time_to_die) {
+ if (CtdlThreadCheckStop()) {
lprintf(CTDL_DEBUG, "Indexer quitting early\n");
ft_newhighest = ft_newmsgs[i];
break;
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);
indexerCC.cs_pid = 0;
pthread_setspecific(MyConKey, (void *)&indexerCC );
- cdb_allocate_tsd();
-
- while (!time_to_die) {
+ while (!CtdlThreadCheckStop()) {
do_fulltext_indexing();
- sleep(1);
+ CtdlThreadSleep(300);
}
lprintf(CTDL_DEBUG, "indexer_thread() exiting\n");
- pthread_exit(NULL);
+ return NULL;
}
CTDL_MODULE_INIT(fulltext)
{
- initialize_ft_cache();
- CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
- CtdlRegisterDeleteHook(ft_delete_remove);
- CtdlRegisterSearchFuncHook(ft_search, "fulltext");
- CtdlRegisterMaintenanceThread ("indexer", indexer_thread);
-
+ if (!threading)
+ {
+ initialize_ft_cache();
+ CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
+ CtdlRegisterDeleteHook(ft_delete_remove);
+ CtdlRegisterSearchFuncHook(ft_search, "fulltext");
+ }
+ else
+ {
+ CtdlThreadCreate("Indexer", CTDLTHREAD_BIGSTACK, indexer_thread, NULL);
+ }
/* return our Subversion id for the Log */
return "$Id$";
}