X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fhousekeeping.c;fp=citadel%2Fhousekeeping.c;h=92336277733acaaeaab8a0bd9145dfeea0cf7ee6;hp=11be04e0092133b4cbee41498bce0abfe67cec04;hb=9571de81331e169c042c630800bff1bde499c8a9;hpb=c51a64e8f8b42b6efd85f17c91178437d73a9c3d diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 11be04e00..923362777 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -129,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