diff --git a/src/defrag.c b/src/defrag.c index 21e729046..6cc100aef 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -1554,12 +1554,6 @@ static int activeDefragTimeProc(struct aeEventLoop *eventLoop, long long id, voi monotime endtime = starttime + dutyCycleUs; int haveMoreWork = 1; - /* Increment server.cronloops so that run_with_period works. */ - long hz_ms = 1000 / server.hz; - int cronloops = (server.mstime - server.blocked_last_cron + (hz_ms - 1)) / hz_ms; /* rounding up */ - server.blocked_last_cron += cronloops * hz_ms; - server.cronloops += cronloops; - mstime_t latency; latencyStartMonitor(latency); diff --git a/src/server.c b/src/server.c index 3b343901e..78efab5bb 100644 --- a/src/server.c +++ b/src/server.c @@ -1703,6 +1703,12 @@ void whileBlockedCron(void) { if (server.blocked_last_cron >= server.mstime) return; + /* Increment server.cronloops so that run_with_period works. */ + long hz_ms = 1000 / server.hz; + int cronloops = (server.mstime - server.blocked_last_cron + (hz_ms - 1)) / hz_ms; /* rounding up */ + server.blocked_last_cron += cronloops * hz_ms; + server.cronloops += cronloops; + mstime_t latency; latencyStartMonitor(latency);