diff --git a/cmdline/state.c b/cmdline/state.c index 1fbc564b..06b27d89 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -5839,13 +5839,15 @@ static void state_progress_graph(struct snapraid_state* state, struct snapraid_i int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize) { time_t now; + uint64_t thermal_now; int pred; now = time(0); + thermal_now = os_tick_sec(); /* thermal measure */ - if (now > state->thermal_latest + THERMAL_PERIOD_SECONDS || state->opt.fake_device) { - state->thermal_latest = now; + if (thermal_now > state->thermal_latest + THERMAL_PERIOD_SECONDS || state->opt.fake_device) { + state->thermal_latest = thermal_now; state_thermal(state, now); } diff --git a/cmdline/state.h b/cmdline/state.h index 368728c8..c97b304d 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -161,8 +161,8 @@ struct snapraid_state { int thermal_stop_gathering; /**< If thermal data gathering is stopped */ int thermal_ambient_temperature; /**< Ambient themperature. 0 if not available */ int thermal_highest_temperature; /**< Current highest temperature */ - time_t thermal_first; /**< Time of the first measure */ - time_t thermal_latest; /**< Time of latest measure */ + uint64_t thermal_first; /**< Monotonic time of the first measure */ + uint64_t thermal_latest; /**< Monotonic time of latest measure */ int thermal_cooldown_time; /**< Cooldown wait time in seconds */ int thermal_temperature_limit; /**< Upper limit temperature of the operating range */ diff --git a/cmdline/thermal.c b/cmdline/thermal.c index 5496fd09..a306fc78 100644 --- a/cmdline/thermal.c +++ b/cmdline/thermal.c @@ -265,7 +265,7 @@ int state_thermal(struct snapraid_state* state, time_t now) /* insert the new data point */ found->data[found->count].temperature = temperature; - found->data[found->count].time = now - state->thermal_first; + found->data[found->count].time = state->thermal_latest - state->thermal_first; ++found->count; if (state->opt.fake_device) { @@ -386,8 +386,8 @@ int state_thermal_begin(struct snapraid_state* state, time_t now) return 1; /* initial thermal measure */ - state->thermal_first = now; - state->thermal_latest = now; + state->thermal_first = os_tick_sec(); + state->thermal_latest = state->thermal_first; state_thermal(state, now); if (state->thermal_ambient_temperature != 0) {