Completed a pair of functions to fetch the user preferences at the beginning of an...
[citadel.git] / citadel / modules / fulltext / serv_fulltext.c
index 681262b4e67aa4aca5c99667d61f94bbed35eb29..8e668778817a405208c55cc6ab3ffd7e34f217ad 100644 (file)
@@ -142,9 +142,8 @@ void ft_index_message(long msgnum, int op) {
        CtdlFreeMessage(msg);
        msgtext = CC->redirect_buffer;
        CC->redirect_buffer = NULL;
-       syslog(LOG_DEBUG, "Wordbreaking message %ld...", msgnum);
-       if ((msgtext == NULL) || (StrLength(msgtext) == 0)) {
-               syslog(LOG_ALERT, "This message has a zero length.  Probable data corruption.");
+       if (msgtext != NULL) {
+               syslog(LOG_DEBUG, "Wordbreaking message %ld (%d bytes)", msgnum, StrLength(msgtext));
        }
        txt = SmashStrBuf(&msgtext);
        wordbreaker(txt, &num_tokens, &tokens);
@@ -415,28 +414,29 @@ void ft_search(int *fts_num_msgs, long **fts_msgs, const char *search_string) {
 
                }
                free(tokens);
-               qsort(all_msgs, num_all_msgs, sizeof(long), longcmp);
-
-               /*
-                * At this point, if a message appears num_tokens times in the
-                * list, then it contains all of the search tokens.
-                */
-               if (num_all_msgs >= num_tokens)
-                  for (j=0; j<(num_all_msgs-num_tokens+1); ++j) {
-                       if (all_msgs[j] == all_msgs[j+num_tokens-1]) {
-
-                               ++num_ret_msgs;
-                               if (num_ret_msgs > num_ret_alloc) {
-                                       num_ret_alloc += 64;
-                                       ret_msgs = realloc(ret_msgs,
-                                               (num_ret_alloc*sizeof(long)) );
+               if (all_msgs != NULL) {
+                       qsort(all_msgs, num_all_msgs, sizeof(long), longcmp);
+
+                       /*
+                        * At this point, if a message appears num_tokens times in the
+                        * list, then it contains all of the search tokens.
+                        */
+                       if (num_all_msgs >= num_tokens)
+                               for (j=0; j<(num_all_msgs-num_tokens+1); ++j) {
+                                       if (all_msgs[j] == all_msgs[j+num_tokens-1]) {
+                                               
+                                               ++num_ret_msgs;
+                                               if (num_ret_msgs > num_ret_alloc) {
+                                                       num_ret_alloc += 64;
+                                                       ret_msgs = realloc(ret_msgs,
+                                                                          (num_ret_alloc*sizeof(long)) );
+                                               }
+                                               ret_msgs[num_ret_msgs - 1] = all_msgs[j];
+                                               
+                                       }
                                }
-                               ret_msgs[num_ret_msgs - 1] = all_msgs[j];
-
-                       }
+                       free(all_msgs);
                }
-
-               free(all_msgs);
        }
 
        *fts_num_msgs = num_ret_msgs;
@@ -506,7 +506,7 @@ CTDL_MODULE_INIT(fulltext)
                CtdlRegisterDeleteHook(ft_delete_remove);
                CtdlRegisterSearchFuncHook(ft_search, "fulltext");
                CtdlRegisterCleanupHook(noise_word_cleanup);
-               CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER);
+               CtdlRegisterSessionHook(do_fulltext_indexing, EVT_TIMER, PRIO_CLEANUP + 300);
        }
        /* return our module name for the log */
        return "fulltext";