Make state_thermal_cooldown() repeat until disks cool down or thermal check fails

This commit is contained in:
Andrea Mazzoleni 2026-09-06 23:08:48 +02:00
parent 2fd94baa05
commit ea955eedc7

View file

@ -330,16 +330,19 @@ int state_thermal_alarm(struct snapraid_state* state)
void state_thermal_cooldown(struct snapraid_state* state) void state_thermal_cooldown(struct snapraid_state* state)
{ {
int sleep_time = state->thermal_cooldown_time; int cooldown_time = state->thermal_cooldown_time;
if (sleep_time == 0) if (cooldown_time == 0)
sleep_time = 5 * 60; /* default sleep time */ cooldown_time = 5 * 60; /* default sleep time */
if (sleep_time < 3 * 60) if (cooldown_time < 3 * 60)
sleep_time = 3 * 60; /* minimum sleep time */ cooldown_time = 3 * 60; /* minimum sleep time */
/* from now on, stop any further data gathering as the heating is interrupted */ /* from now on, stop any further data gathering as the heating is interrupted */
state->thermal_stop_gathering = 1; state->thermal_stop_gathering = 1;
for (;;) {
int sleep_time = cooldown_time;
log_tag("thermal:spindown\n"); log_tag("thermal:spindown\n");
state_device(state, DEVICE_DOWN, 0); state_device(state, DEVICE_DOWN, 0);
@ -358,14 +361,21 @@ void state_thermal_cooldown(struct snapraid_state* state)
sleep_time -= 30; sleep_time -= 30;
} }
if (!os_signal_interrupt()) { /* don't wake-up if we are interrupting */ if (os_signal_interrupt())
break; /* don't wake-up if we are interrupting */
log_tag("thermal:spinup\n"); log_tag("thermal:spinup\n");
/* spinup */ /* spinup */
state_device(state, DEVICE_UP, 0); state_device(state, DEVICE_UP, 0);
/* log new thermal info */ /* log new thermal info */
state_thermal(state, 0); if (state_thermal(state, 0) != 0)
break;
/* repeat the cooldown if the temperature is still outside the operating range */
if (!state_thermal_alarm(state))
break;
} }
} }