|
@@ -200,7 +200,7 @@ static UA_StatusCode addRepeatedJob(UA_Server *server, struct AddRepeatedJob * U
|
|
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
|
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
|
|
|
|
|
/* search for matching entry */
|
|
/* search for matching entry */
|
|
- UA_DateTime firstTime = UA_DateTime_nowMonotonic();
|
|
|
|
|
|
+ UA_DateTime firstTime = UA_DateTime_nowMonotonic() + arw->interval;
|
|
tempTw = LIST_FIRST(&server->repeatedJobs);
|
|
tempTw = LIST_FIRST(&server->repeatedJobs);
|
|
while(tempTw) {
|
|
while(tempTw) {
|
|
if(arw->interval == tempTw->interval) {
|
|
if(arw->interval == tempTw->interval) {
|
|
@@ -310,18 +310,18 @@ static UA_DateTime processRepeatedJobs(UA_Server *server, UA_DateTime current) {
|
|
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
|
|
- size_t size = tw->jobsSize;
|
|
|
|
|
|
+ size_t size = tw->jobsSize;
|
|
for(size_t i = 0; i < size; i++)
|
|
for(size_t i = 0; i < size; i++)
|
|
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
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- /* Elements are removed only here. Check if empty. */
|
|
|
|
- if(tw->jobsSize == 0) {
|
|
|
|
- LIST_REMOVE(tw, pointers);
|
|
|
|
- UA_free(tw);
|
|
|
|
|
|
+ /* Elements are removed only here. Check if empty. */
|
|
|
|
+ if(tw->jobsSize == 0) {
|
|
|
|
+ LIST_REMOVE(tw, pointers);
|
|
|
|
+ UA_free(tw);
|
|
UA_assert(LIST_FIRST(&server->repeatedJobs) != tw); /* Assert for static code checkers */
|
|
UA_assert(LIST_FIRST(&server->repeatedJobs) != tw); /* Assert for static code checkers */
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
/* Set the time for the next execution */
|
|
/* Set the time for the next execution */
|
|
tw->nextTime += tw->interval;
|
|
tw->nextTime += tw->interval;
|
|
@@ -358,7 +358,7 @@ static void removeRepeatedJob(UA_Server *server, UA_Guid *jobId) {
|
|
for(size_t i = 0; i < tw->jobsSize; i++) {
|
|
for(size_t i = 0; i < tw->jobsSize; i++) {
|
|
if(!UA_Guid_equal(jobId, &tw->jobs[i].id))
|
|
if(!UA_Guid_equal(jobId, &tw->jobs[i].id))
|
|
continue;
|
|
continue;
|
|
- tw->jobsSize--; /* if size == 0, tw is freed during the next processing */
|
|
|
|
|
|
+ tw->jobsSize--; /* if size == 0, tw is freed during the next processing */
|
|
if(tw->jobsSize > 0)
|
|
if(tw->jobsSize > 0)
|
|
tw->jobs[i] = tw->jobs[tw->jobsSize]; // move the last entry to overwrite
|
|
tw->jobs[i] = tw->jobs[tw->jobsSize]; // move the last entry to overwrite
|
|
goto finish;
|
|
goto finish;
|