X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Ffulltext%2Fserv_fulltext.c;h=9fc9cf5b0ac9163b8d725512fced5c8bcdda03a5;hb=a520d904d0069654c57d2b69618bee1225ee3067;hp=4fced5e28ac95b2a7eaebf00ec992b8e524605a8;hpb=a0273902a9c58482e88c26399fec4670ade79387;p=citadel.git diff --git a/citadel/modules/fulltext/serv_fulltext.c b/citadel/modules/fulltext/serv_fulltext.c index 4fced5e28..9fc9cf5b0 100644 --- a/citadel/modules/fulltext/serv_fulltext.c +++ b/citadel/modules/fulltext/serv_fulltext.c @@ -1,6 +1,6 @@ /* * This module handles fulltext indexing of the message base. - * Copyright (c) 2005-2017 by the citadel.org team + * Copyright (c) 2005-2021 by the citadel.org team * * This program is open source software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -80,6 +80,7 @@ int longcmp(const void *rec1, const void *rec2) { return(0); } + /* * Flush our index cache out to disk. */ @@ -120,7 +121,7 @@ void ft_index_message(long msgnum, int op) { int tok; struct CtdlMessage *msg = NULL; - msg = CtdlFetchMessage(msgnum, 1, 1); + msg = CtdlFetchMessage(msgnum, 1); if (msg == NULL) { syslog(LOG_ERR, "fulltext: ft_index_message() could not load msg %ld", msgnum); return; @@ -204,7 +205,6 @@ void ft_index_message(long msgnum, int op) { } - /* * Add a message to the list of those to be indexed. */ @@ -214,14 +214,14 @@ void ft_index_msg(long msgnum, void *userdata) { ++ft_num_msgs; if (ft_num_msgs > ft_num_alloc) { ft_num_alloc += 1024; - ft_newmsgs = realloc(ft_newmsgs, - (ft_num_alloc * sizeof(long))); + ft_newmsgs = realloc(ft_newmsgs, (ft_num_alloc * sizeof(long))); } ft_newmsgs[ft_num_msgs - 1] = msgnum; } } + /* * Scan a room for messages to index. */ @@ -240,7 +240,6 @@ void ft_index_room(struct ctdlroom *qrbuf, void *data) */ void do_fulltext_indexing(void) { int i; - static time_t last_index = 0L; static time_t last_progress = 0L; static int is_running = 0; if (is_running) return; /* Concurrency check - only one can run */ @@ -254,32 +253,7 @@ void do_fulltext_indexing(void) { } /* - * Make sure we don't run the indexer too frequently. - * FIXME move the setting into config - time_t now = time(NULL); - if ( (now - last_index) < 300L) { - syslog(LOG_DEBUG, - "fulltext: indexing interval not yet reached; last run was %ldm%lds ago", - ((now - last_index) / 60), - ((now - last_index) % 60) - ); - return; - } - */ - - /* - * Silently return if our fulltext index is up to date with new messages. - */ - if ( - (CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest")) - && (CtdlGetConfigInt("MM_fulltext_wordbreaker") == FT_WORDBREAKER_ID) - ) { - return; /* nothing to do! */ - } - - /* - * If we've switched wordbreaker modules, burn the index and start - * over. + * If we've switched wordbreaker modules, burn the index and start over. */ begin_critical_section(S_CONTROL); if (CtdlGetConfigInt("MM_fulltext_wordbreaker") != FT_WORDBREAKER_ID) { @@ -292,6 +266,13 @@ void do_fulltext_indexing(void) { } end_critical_section(S_CONTROL); + /* + * Silently return if our fulltext index is up to date with new messages. + */ + if ((CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest"))) { + return; /* nothing to do! */ + } + /* * Now go through each room and find messages to index. */ @@ -354,7 +335,6 @@ void do_fulltext_indexing(void) { CtdlSetConfigLong("MMfulltext", ft_newhighest); CtdlSetConfigInt("MM_fulltext_wordbreaker", FT_WORDBREAKER_ID); end_critical_section(S_CONTROL); - last_index = time(NULL); syslog(LOG_DEBUG, "fulltext: indexing finished"); is_running = 0; @@ -362,7 +342,6 @@ void do_fulltext_indexing(void) { } - /* * API call to perform searches. * (This one does the "all of these words" search.) @@ -472,6 +451,7 @@ void cmd_srch(char *argbuf) { cprintf("000\n"); } + /* * Zero out our index cache. */ @@ -491,6 +471,7 @@ void ft_delete_remove(char *room, long msgnum) } } + /*****************************************************************************/ CTDL_MODULE_INIT(fulltext) @@ -498,11 +479,9 @@ CTDL_MODULE_INIT(fulltext) if (!threading) { initialize_ft_cache(); - initialize_noise_words(); CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search"); CtdlRegisterDeleteHook(ft_delete_remove); CtdlRegisterSearchFuncHook(ft_search, "fulltext"); - CtdlRegisterCleanupHook(noise_word_cleanup); CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER, PRIO_CLEANUP + 300); } /* return our module name for the log */