Browse Source

fix: improve reactivity under high load (#655)

So far, it was possible to have so many repeated jobs, that processing
took more time than the repetition interval. In that case,
processRepeatedJobs stuck in a loop. The problem is fixed by ensuring
that the next repetition is schedule "after" the current time.
Julius Pfrommer 8 years ago
parent
commit
0b2cec1002
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/server/ua_server_worker.c

+ 3 - 1
src/server/ua_server_worker.c

@@ -247,7 +247,9 @@ processRepeatedJobs(UA_Server *server, UA_DateTime current) {
         /* Set the time for the next execution */
         rj->nextTime += (UA_Int64)rj->interval;
         if(rj->nextTime < current)
-            rj->nextTime = current;
+            rj->nextTime = current + 1; /* prevent to rerun the job right now
+                                           when the repeated jobs took more time
+                                           than rj->interval */
 
         /* Keep the list sorted */
         struct RepeatedJob *prev_rj = lastNow;