Skip to content

Commit

Permalink
Merge pull request #251 from lf-lang/fix-error-during-shutdown
Browse files Browse the repository at this point in the history
Fix for fatal error raised during shutdown when decrementing a tag barrier that is zero
  • Loading branch information
lhstrh authored Jul 21, 2023
2 parents aaeadfa + b23c8c5 commit b9f423b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2031,20 +2031,19 @@ void handle_tagged_message(int socket, int fed_id) {
// Before that, if the current time >= stop time, discard the message.
// But only if the stop time is not equal to the start time!
if (lf_tag_compare(env->current_tag, env->stop_tag) >= 0) {
lf_mutex_unlock(&env->mutex);
lf_print_error("Received message too late. Already at stop tag.\n"
"Current tag is " PRINTF_TAG " and intended tag is " PRINTF_TAG ".\n"
"Discarding message.",
env->current_tag.time - start_time, env->current_tag.microstep,
intended_tag.time - start_time, intended_tag.microstep);
return;
goto release;
}

LF_PRINT_LOG("Calling schedule with tag " PRINTF_TAG ".", intended_tag.time - start_time, intended_tag.microstep);
schedule_message_received_from_network_locked(env, action->trigger, intended_tag, message_token);
}


release:
#ifdef FEDERATED_DECENTRALIZED // Only applicable for federated programs with decentralized coordination
// Finally, decrement the barrier to allow the execution to continue
// past the raised barrier
Expand Down Expand Up @@ -2333,7 +2332,7 @@ void handle_stop_granted_message() {
env[i].stop_tag.time - start_time,
env[i].stop_tag.microstep);

_lf_decrement_tag_barrier_locked(&env[i]);
if (env[i].barrier.requestors) _lf_decrement_tag_barrier_locked(&env[i]);
// We signal instead of broadcast under the assumption that only
// one worker thread can call wait_until at a given time because
// the call to wait_until is protected by a mutex lock
Expand Down

0 comments on commit b9f423b

Please sign in to comment.