Branch: Tag:

2022-09-13

2022-09-13 14:09:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>

FSGC: Add global settings for controlling when the fsgc is to run.

Fixes [REP-713].

15:   #define GC_WERR(X...)   #endif    + // The following are mixed in when inherited by roxen.pike. + Variable.Variable getvar( string name ); +    /* Some notes:    *    * There are multiple data for a file that may affect the garbage policy:
499:    // Sleep a bit to avoid the startup race.    sleep(60);    while(meta_fsgc_thread) { -  int max_sleep = 60; +  int max_sleep = 300; +  int next_start = getvar("fsgc_starttime")->get_next(0); +  int next_stop = getvar("fsgc_stoptime")->get_next(0); +  +  if (next_start < 0) { +  // FSGC Disabled +  GC_WERR("FSGC: Disabled.\n"); +  } else if (next_start < next_stop) { +  // FSGC Not allowed to run now. +  // Sleep until next start time, but max 5 minutes +  // at a time in case the settings are changed. +  max_sleep = next_start - time(1); +  if (max_sleep > 300) { +  max_sleep = 300; +  } +  } else { +  // FSGC Allowed to run. +  max_sleep = 60;    foreach(fsgarbs; string id; FSGarb g) {    int seconds = g && g->check();    if (seconds < max_sleep) max_sleep = seconds;    }    if (max_sleep < 1) max_sleep = 1; -  +  }    GC_WERR("FSGC: Sleeping %d seconds...\n", max_sleep);    while(meta_fsgc_thread && max_sleep--) {    sleep(1);