]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_fulltext.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_fulltext.c
index 2c23d49dc09b30387fe1e7785d2f9a6dd0396778..f6e2c672a8902f0a07be23f3a4c18b7a39e27fa9 100644 (file)
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "serv_extensions.h"
 #include "database.h"
 #include "msgbase.h"
 #include "control.h"
 #include "ft_wordbreaker.h"
 
 
+#include "ctdl_module.h"
+
+
+
 long ft_newhighest = 0L;
 long *ft_newmsgs = NULL;
 int ft_num_msgs = 0;
@@ -175,8 +177,6 @@ void ft_index_message(long msgnum, int op) {
                        else {
                                lprintf(CTDL_ALERT, "Invalid token %d !!\n", tok);
                        }
-
-                       /* FIXME do we need to unlock the file here? */
                }
 
                free(tokens);
@@ -208,7 +208,7 @@ void ft_index_msg(long msgnum, void *userdata) {
 void ft_index_room(struct ctdlroom *qrbuf, void *data)
 {
        getroom(&CC->room, qrbuf->QRname);
-       CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, ft_index_msg, NULL);
+       CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, ft_index_msg, NULL);
 }
 
 
@@ -249,12 +249,16 @@ void do_fulltext_indexing(void) {
         * If we've switched wordbreaker modules, burn the index and start
         * over.
         */
+       begin_critical_section(S_CONTROL);
+       lprintf(CTDL_DEBUG, "wb ver on disk = %d, code ver = %d\n",
+                       CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID);
        if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
                lprintf(CTDL_INFO, "(re)initializing full text index\n");
                cdb_trunc(CDB_FULLTEXT);
                CitControl.MMfulltext = 0L;
                put_control();
        }
+       end_critical_section(S_CONTROL);
 
        /*
         * Now go through each room and find messages to index.
@@ -275,7 +279,7 @@ void do_fulltext_indexing(void) {
 
                /* Here it is ... do each message! */
                for (i=0; i<ft_num_msgs; ++i) {
-                       if ((time(NULL) - last_progress) > 10) {
+                       if (time(NULL) != last_progress) {
                                lprintf(CTDL_DEBUG,
                                        "Indexed %d of %d messages (%d%%)\n",
                                                i, ft_num_msgs,
@@ -309,9 +313,11 @@ void do_fulltext_indexing(void) {
 
        /* Save our place so we don't have to do this again */
        ft_flush_cache();
+       begin_critical_section(S_CONTROL);
        CitControl.MMfulltext = ft_newhighest;
        CitControl.fulltext_wordbreaker = FT_WORDBREAKER_ID;
        put_control();
+       end_critical_section(S_CONTROL);
        last_index = time(NULL);
 
        lprintf(CTDL_DEBUG, "do_fulltext_indexing() finished\n");
@@ -463,9 +469,11 @@ void initialize_ft_cache(void) {
 
 /*****************************************************************************/
 
-char *serv_fulltext_init(void)
+CTDL_MODULE_INIT(fulltext)
 {
        initialize_ft_cache();
        CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
+
+       /* return our Subversion id for the Log */
        return "$Id$";
 }