Procházet zdrojové kódy

use the worker fix from the master branch

Julius Pfrommer před 9 roky
rodič
revize
dc9eb50856
1 změnil soubory, kde provedl 7 přidání a 13 odebrání
  1. 7 13
      src/server/ua_server_worker.c

+ 7 - 13
src/server/ua_server_worker.c

@@ -325,10 +325,9 @@ UA_StatusCode UA_Server_addRepeatedJob(UA_Server *server, UA_Job job, UA_UInt32
 /* Returns the timeout until the next repeated job in ms */
 /* Returns the timeout until the next repeated job in ms */
 static UA_UInt16 processRepeatedJobs(UA_Server *server) {
 static UA_UInt16 processRepeatedJobs(UA_Server *server) {
     UA_DateTime current = UA_DateTime_now();
     UA_DateTime current = UA_DateTime_now();
-    struct RepeatedJobs *tw = LIST_FIRST(&server->repeatedJobs);
+    struct RepeatedJobs *tw = UA_NULL;
 
 
-    while (tw) {
-        //tw = nextjob;
+    while((tw = LIST_FIRST(&server->repeatedJobs)) != UA_NULL) {
         if(tw->nextTime > current)
         if(tw->nextTime > current)
             break;
             break;
 
 
@@ -343,28 +342,23 @@ static UA_UInt16 processRepeatedJobs(UA_Server *server) {
             jobsCopy[i] = tw->jobs[i].job;
             jobsCopy[i] = tw->jobs[i].job;
         dispatchJobs(server, jobsCopy, tw->jobsSize); // frees the job pointer
         dispatchJobs(server, jobsCopy, tw->jobsSize); // frees the job pointer
 #else
 #else
-        for (size_t i = 0; i < tw->jobsSize; i++)
-        {
-            // be carefull
-            // methodCall may sort the list but dont delete entries
+        for(size_t i=0;i<tw->jobsSize;i++)
+            //processJobs may sort the list but dont delete entries
             processJobs(server, &tw->jobs[i].job, 1); // does not free the job ptr
             processJobs(server, &tw->jobs[i].job, 1); // does not free the job ptr
-            // LIST_NEXT(tw, pointers) is still vaid
-        }
 #endif
 #endif
         tw->nextTime += tw->interval;
         tw->nextTime += tw->interval;
-        struct RepeatedJobs *prevTw = tw; // after which tw do we insert?
+        //start iterating the list from the beginning
+        struct RepeatedJobs *prevTw = LIST_FIRST(&server->repeatedJobs); // after which tw do we insert?
         while(UA_TRUE) {
         while(UA_TRUE) {
             struct RepeatedJobs *n = LIST_NEXT(prevTw, pointers);
             struct RepeatedJobs *n = LIST_NEXT(prevTw, pointers);
             if(!n || n->nextTime > tw->nextTime)
             if(!n || n->nextTime > tw->nextTime)
                 break;
                 break;
             prevTw = n;
             prevTw = n;
         }
         }
-        struct RepeatedJobs *nextTw = LIST_NEXT(tw, pointers);
-        if (prevTw != tw) {
+        if(prevTw != tw) {
             LIST_REMOVE(tw, pointers);
             LIST_REMOVE(tw, pointers);
             LIST_INSERT_AFTER(prevTw, tw, pointers);
             LIST_INSERT_AFTER(prevTw, tw, pointers);
         }
         }
-        tw = nextTw;
     }
     }
 
 
     // check if the next repeated job is sooner than the usual timeout
     // check if the next repeated job is sooner than the usual timeout