X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fhousekeeping.c;h=92336277733acaaeaab8a0bd9145dfeea0cf7ee6;hb=cbc736c6fd45401b653454914a1b437050600a00;hp=077b509300c002433aa5f21cd9a26d9f84b6d689;hpb=314acc50c58e49fb9a5df9d7f0c24b2535ba0757;p=citadel.git diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 077b50930..923362777 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -12,49 +12,15 @@ * GNU General Public License for more details. */ -#include "sysdep.h" -#include -#include #include -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_SELECT_H -#include -#endif -#include #include -#include "citadel.h" -#include "server.h" + +#include "ctdl_module.h" #include "serv_extensions.h" -#include "citserver.h" -#include "config.h" -#include "housekeeping.h" -#include "sysdep_decls.h" #include "room_ops.h" -#include "database.h" -#include "msgbase.h" #include "internet_addressing.h" #include "journaling.h" -#include "ctdl_module.h" -#include "threads.h" - void check_sched_shutdown(void) { if ((ScheduledShutdown == 1) && (ContextList == NULL)) { syslog(LOG_NOTICE, "Scheduled shutdown initiating.\n"); @@ -163,3 +129,60 @@ void do_housekeeping(void) { housekeeping_in_progress = 0; end_critical_section(S_HOUSEKEEPING); } + +void CtdlDisableHouseKeeping(void) +{ + int ActiveBackgroundJobs; + int do_housekeeping_now = 0; + struct CitContext *nptr; + int nContexts, i; + +retry_block_housekeeping: + syslog(LOG_INFO, "trying to disable housekeeping services"); + begin_critical_section(S_HOUSEKEEPING); + if (housekeeping_in_progress == 0) { + do_housekeeping_now = 1; + housekeeping_in_progress = 1; + } + end_critical_section(S_HOUSEKEEPING); + if (do_housekeeping_now == 0) { + usleep(1000000); + goto retry_block_housekeeping; + } + + syslog(LOG_INFO, "checking for running server Jobs"); + +retry_wait_for_contexts: + /* So that we don't keep the context list locked for a long time + * we create a copy of it first + */ + ActiveBackgroundJobs = 0; + nptr = CtdlGetContextArray(&nContexts) ; + if (nptr) + { + for (i=0; i