Skip to content

Commit

Permalink
Reject events that are tried scheduled before start tag
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Jan 23, 2025
1 parent 5144e03 commit 52dcc7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/federated.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ void FederatedConnectionBundle_handle_tagged_msg(FederatedConnectionBundle *self
env->platform->new_async_event(env->platform);
}
break;
case LF_INVALID_TAG:
break;
case LF_OK:
env->platform->new_async_event(env->platform);
break;
Expand Down
8 changes: 8 additions & 0 deletions src/schedulers/dynamic/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ lf_ret_t Scheduler_schedule_at_locked(Scheduler *untyped_self, Event *event) {
return LF_PAST_TAG;
}

// Check if we are trying to schedule before the start tag
tag_t start_tag = {.time = self->super.start_time, .microstep = 0};
if (lf_tag_compare(event->tag, start_tag) < 0 || self->super.start_time == NEVER) {
LF_WARN(SCHED, "Trying to schedule trigger %p at tag %" PRId64 ":%" PRIu32 " which is before start tag",
event->trigger, event->tag.time, event->tag.microstep);
return LF_INVALID_TAG;
}

lf_ret_t ret = self->event_queue.insert(&self->event_queue, event);
if (ret != LF_OK) {
LF_ERR(SCHED, "Failed to insert event into event queue");
Expand Down

0 comments on commit 52dcc7c

Please sign in to comment.