From 5bf374c0ab3e3e339dc048789f3d121668380d3b Mon Sep 17 00:00:00 2001 From: Justin Case Date: Fri, 3 Mar 2017 18:48:36 +0100 Subject: [PATCH] job.c: Fix timeout calculation until next event Subtracting the awakeme time from the current time is usually negative, causing the loop to continuously run at 1ms intervals. --- src/job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job.c b/src/job.c index 6ce564e..d6912b2 100644 --- a/src/job.c +++ b/src/job.c @@ -584,7 +584,7 @@ int processJobs(struct aeEventLoop *eventLoop, long long id, void *clientData) { current = server.awakeme->header->level[0].forward; if (current) { job *j = current->obj; - period = server.mstime-j->awakeme; + period = j->awakeme - server.mstime; if (period < 1) period = 1; else if (period > 100) period = 100; }