Skip to content

Commit

Permalink
planner: ensure result in planner_avail_resources_at
Browse files Browse the repository at this point in the history
During restart, we can end up in a situation where a time before the
planner's base is requested, in this case negative time, so there's no
earlier time to return from get_state. It feels like get_state should
always return *some kind of state*, but it's not clear how to do that
and avoid accidentally pretending there are no resource available. This
avoids asking for that invalid state by checking the precondition in the
planner, if an `at` before the `plan_start` is requested it's treated as
an invalid argument.
  • Loading branch information
trws committed Jun 20, 2023
1 parent c65026c commit e3cb566
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion resource/planner/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ extern "C" int64_t planner_avail_resources_during (planner_t *ctx,
extern "C" int64_t planner_avail_resources_at (planner_t *ctx, int64_t at)
{
scheduled_point_t *state = nullptr;
if (!ctx || at > ctx->plan_end) {
if (!ctx || at > ctx->plan_end || at < ctx->plan_start) {
errno = EINVAL;
return -1;
}
Expand Down

0 comments on commit e3cb566

Please sign in to comment.