diff --git a/HISTORY b/HISTORY index b04497c..ea16776 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,4 @@ -Version 1.08 2014-10-08 +Version 1.08 2014-10-09 * sched_thread.c: calculate next_call_time correctly Version 1.07 2014-09-16 diff --git a/src/sched_thread.c b/src/sched_thread.c index 7dbb8a8..ab82e86 100644 --- a/src/sched_thread.c +++ b/src/sched_thread.c @@ -269,7 +269,6 @@ static void *sched_thread_entrance(void *args) ScheduleEntry *pUntil; int exec_count; int i; - int sleep_time; pContext = (ScheduleContext *)args; if (sched_init_entries(&(pContext->scheduleArray)) != 0) @@ -291,22 +290,16 @@ static void *sched_thread_entrance(void *args) } g_current_time = time(NULL); - sleep_time = pContext->head->next_call_time - g_current_time; - - /* - //fprintf(stderr, "count=%d, sleep_time=%d\n", \ - pContext->scheduleArray.count, sleep_time); - */ - while (sleep_time > 0 && *(pContext->pcontinue_flag)) - { - sleep(1); - g_current_time = time(NULL); - if (sched_check_waiting(pContext) == 0) - { - break; - } - sleep_time--; - } + while (pContext->head->next_call_time > g_current_time && + *(pContext->pcontinue_flag)) + { + sleep(1); + g_current_time = time(NULL); + if (sched_check_waiting(pContext) == 0) + { + break; + } + } if (!(*(pContext->pcontinue_flag))) {