From f33d6cdeeba0b9a43ba5f753a6c50aca5e4c9b66 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 29 Aug 2023 15:03:34 -0400 Subject: [PATCH] CtdlForEachMessage() don't process message 0 --- citadel/server/citadel_defs.h | 2 +- citadel/server/housekeeping.c | 6 +++++- citadel/server/modules/fulltext/serv_fulltext.c | 2 ++ citadel/server/modules_init.c | 2 +- citadel/server/msgbase.c | 2 +- citadel/server/sysdep.c | 12 +++--------- citadel/server/threads.c | 14 +------------- 7 files changed, 14 insertions(+), 26 deletions(-) diff --git a/citadel/server/citadel_defs.h b/citadel/server/citadel_defs.h index 2e306a20e..a879c4631 100644 --- a/citadel/server/citadel_defs.h +++ b/citadel/server/citadel_defs.h @@ -27,7 +27,7 @@ #define LIBCITADEL_MIN 951 // Minimum required version of libcitadel #define SERVER_TYPE 0 // zero for stock Citadel; other developers please obtain SERVER_TYPE codes for your implementations -#define TRACE syslog(LOG_DEBUG, "\033[7m Checkpoint: %s : %d \033[0m", __FILE__, __LINE__) +#define TRACE syslog(LOG_DEBUG, "\033[7m Checkpoint: %p : %s : %d \033[0m", CC, __FILE__, __LINE__) #ifndef LONG_MAX #define LONG_MAX 2147483647L diff --git a/citadel/server/housekeeping.c b/citadel/server/housekeeping.c index 55e7e77d6..5ce28bf81 100644 --- a/citadel/server/housekeeping.c +++ b/citadel/server/housekeeping.c @@ -88,7 +88,7 @@ void do_housekeeping(void) { int do_perminute_housekeeping_now = 0; time_t now; - if (housekeeping_disabled) { + if ( (housekeeping_disabled) || (housekeeping_in_progress) ) { return; } @@ -113,6 +113,10 @@ void do_housekeeping(void) { return; } + if (!do_housekeeping_now) { + return; + } + // Ok, at this point we've made the decision to run the housekeeping // loop. Everything below this point is real work. diff --git a/citadel/server/modules/fulltext/serv_fulltext.c b/citadel/server/modules/fulltext/serv_fulltext.c index b80ade388..4f04baad6 100644 --- a/citadel/server/modules/fulltext/serv_fulltext.c +++ b/citadel/server/modules/fulltext/serv_fulltext.c @@ -60,6 +60,7 @@ void ft_flush_cache(void) { int i; time_t last_update = 0; + cdb_begin_transaction(); for (i=0; i<65536; ++i) { if ((time(NULL) - last_update) >= 10) { syslog(LOG_INFO, "fulltext: flushing index cache to disk (%d%% complete)", (i * 100 / 65536)); @@ -72,6 +73,7 @@ void ft_flush_cache(void) { ftc_msgs[i] = NULL; } } + cdb_end_transaction(); syslog(LOG_INFO, "fulltext: flushed index cache to disk (100%% complete)"); } diff --git a/citadel/server/modules_init.c b/citadel/server/modules_init.c index b27c2fe1b..c6cce4988 100644 --- a/citadel/server/modules_init.c +++ b/citadel/server/modules_init.c @@ -45,7 +45,7 @@ void initialize_modules(int is_threading) { // FIXME // There is something in this module that fux0rs the new backend, causing it to deadlock. - // syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_fulltext()); + syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_fulltext()); syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_image()); syslog(LOG_DEBUG, "extensions: init %s", ctdl_module_init_imap()); diff --git a/citadel/server/msgbase.c b/citadel/server/msgbase.c index 1f1671da4..27c3e51b0 100644 --- a/citadel/server/msgbase.c +++ b/citadel/server/msgbase.c @@ -653,7 +653,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string, } // Now begin the traversal. - if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) { + if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) if (msglist[a] > 0) { // If the caller is looking for a specific MIME type, filter // out all messages which are not of the type requested. diff --git a/citadel/server/sysdep.c b/citadel/server/sysdep.c index cbe62879a..772308e44 100644 --- a/citadel/server/sysdep.c +++ b/citadel/server/sysdep.c @@ -825,8 +825,8 @@ do_select: force_purge = 0; } end_critical_section(S_SESSION_TABLE); - if (bind_me) { - goto SKIP_SELECT; + if (bind_me) { // don't search for a session to bind to. + goto SKIP_SELECT; // we already found one. } // If we got this far, it means that there are no sessions @@ -990,13 +990,7 @@ SKIP_SELECT: } // If control reaches this point, the server is shutting down - while(1) { - sleep(1); // wait to die - } - //pthread_mutex_lock(&ThreadCountMutex); - //--num_workers; - //pthread_mutex_unlock(&ThreadCountMutex); - //return(NULL); + return(NULL); } diff --git a/citadel/server/threads.c b/citadel/server/threads.c index 6b782a673..7fe9d5f38 100644 --- a/citadel/server/threads.c +++ b/citadel/server/threads.c @@ -21,7 +21,6 @@ int active_workers = 0; // Number of ACTIVE worker threads pthread_mutex_t Critters[MAX_SEMAPHORES]; // Things needing locking int server_shutting_down = 0; // set to nonzero during shutdown pthread_mutex_t ThreadCountMutex; -char locks[MAX_SEMAPHORES+1]; void InitializeSemaphores(void) { int i; @@ -29,9 +28,7 @@ void InitializeSemaphores(void) { // Set up a bunch of semaphores to be used for critical sections for (i=0; i