Commit 3af310ce by Tobias Langer Committed by Tobias Langer

Fixed assertion problem in priority queue.

The priority queue relies on setting an invalid time value for
non-existing nodes. However the time comparison checks for valid
embb_time_t types. Therefore prior to doing the time comparison, the
time values have to be checked for validity.
parent 4ec3eafb
...@@ -145,11 +145,16 @@ embb_mtapi_task_t * embb_mtapi_priority_queue_pop(embb_mtapi_priority_queue_t* t ...@@ -145,11 +145,16 @@ embb_mtapi_task_t * embb_mtapi_priority_queue_pop(embb_mtapi_priority_queue_t* t
right_deadline.seconds = ULLONG_MAX; right_deadline.seconds = ULLONG_MAX;
} }
/* min Heap, swap with the smaller of both children. */ /* min Heap, swap with the smaller of both children.
if(embb_time_compare(&left_deadline, &right_deadline) <= 0) { *
* the separate checks are necessary since the comparison operator
* checks whether the time is within certain bounds. */
if(right_deadline.seconds == ULLONG_MAX ||
(left_deadline.seconds != ULLONG_MAX &&
embb_time_compare(&left_deadline, &right_deadline) <= 0)) {
swap = ii + 1; swap = ii + 1;
swap_deadline = left_deadline; swap_deadline = left_deadline;
} else if(embb_time_compare(&left_deadline, &right_deadline) > 0) { } else {
swap = ii + 2; swap = ii + 2;
swap_deadline = right_deadline; swap_deadline = right_deadline;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment