Skip to content

Commit 5975c39

Browse files
committed
Fix bugs due to rebase + Tracepoint lf_stop()
1 parent d0596d1 commit 5975c39

File tree

3 files changed

+26
-73
lines changed

3 files changed

+26
-73
lines changed

core/federated/RTI/rti_remote.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ static void* pending_grant_thread(void* federate) {
273273
* @param fed The federate.
274274
* @param tag The tag to grant.
275275
*/
276-
static void notify_tag_advance_grant_delayed(scheduling_node_t* e, tag_t tag) {
277-
federate_info_t* fed = (federate_info_t*)GET_FED_INFO(e->id);
278-
276+
static void notify_tag_advance_grant_delayed(federate_info_t* fed, tag_t tag) {
279277
// Check wether there is already a pending grant
280278
// And check the pending provisional grant as well
281279
lf_mutex_lock(&rti_mutex);
@@ -418,9 +416,7 @@ static void* pending_provisional_grant_thread(void* federate) {
418416
* @param fed The federate.
419417
* @param tag The provisional tag to grant.
420418
*/
421-
static void notify_provisional_tag_advance_grant_delayed(scheduling_node_t* e, tag_t tag) {
422-
federate_info_t* fed = (federate_info_t*)e;
423-
419+
static void notify_provisional_tag_advance_grant_delayed(federate_info_t* fed, tag_t tag) {
424420
// Proceed with the delayed provisional tag grant notification only if
425421
// there is no pending grant and no provisional pending grant
426422
LF_MUTEX_LOCK(&rti_mutex);
@@ -981,9 +977,10 @@ void send_start_tag(federate_info_t* my_fed, instant_t federation_start_time, ta
981977
// message.
982978
// In the startup phase, federates will receive identical start_time and
983979
// effective_start_tag
984-
unsigned char start_time_buffer[MSG_TYPE_TIMESTAMP_LENGTH];
985-
start_time_buffer[0] = MSG_TYPE_TIMESTAMP;
980+
unsigned char start_time_buffer[MSG_TYPE_TIMESTAMP_START_LENGTH];
981+
start_time_buffer[0] = MSG_TYPE_TIMESTAMP_START;
986982
encode_int64(swap_bytes_if_big_endian_int64(start_time), &start_time_buffer[1]);
983+
encode_tag(&(start_time_buffer[1 + sizeof(instant_t)]), federate_start_tag);
987984

988985
if (rti_remote->base.tracing_enabled) {
989986
tracepoint_rti_to_federate(send_TIMESTAMP, my_fed->enclave.id, &federate_start_tag);
@@ -1509,7 +1506,7 @@ static int32_t receive_and_check_fed_id_message(int* socket_id, struct sockaddr_
15091506
// First byte received is the message type.
15101507
if (buffer[0] != MSG_TYPE_FED_IDS) {
15111508
if (rti_remote->base.tracing_enabled) {
1512-
tracepoint_rti_to_federate(rti_remote->base.trace, send_REJECT, fed_id, NULL);
1509+
tracepoint_rti_to_federate(send_REJECT, fed_id, NULL);
15131510
}
15141511
if (buffer[0] == MSG_TYPE_P2P_SENDING_FED_ID || buffer[0] == MSG_TYPE_P2P_TAGGED_MESSAGE) {
15151512
// The federate is trying to connect to a peer, not to the RTI.
@@ -2022,15 +2019,13 @@ void* lf_connect_to_transient_federates_thread(void* nothing) {
20222019
// The following blocks until a federate connects.
20232020
int socket_id = -1;
20242021
while (1) {
2025-
if (!rti_remote->all_persistent_federates_exited) {
2026-
return NULL;
2027-
}
2022+
// if (!rti_remote->all_persistent_federates_exited) {
2023+
// return NULL;
2024+
// }
20282025
socket_id = accept(rti_remote->socket_descriptor_TCP, &client_fd, &client_length);
20292026
if (socket_id >= 0) {
20302027
// Got a socket
20312028
break;
2032-
} else if (socket_id < 0 && (errno != EAGAIN || errno != EWOULDBLOCK)) {
2033-
lf_print_error_system_failure("RTI failed to accept the socket.");
20342029
} else {
20352030
// Try again
20362031
lf_print_warning("RTI failed to accept the socket. %s. Trying again.", strerror(errno));

core/threaded/reactor_threaded.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,13 @@ void _lf_initialize_start_tag(environment_t* env) {
615615
}
616616

617617
_lf_initialize_timers(env);
618+
env->current_tag = effective_start_tag;
618619

619620
#if defined FEDERATED_DECENTRALIZED
620621
// If we have a non-zero STA offset, then we need to allow messages to arrive
621622
// prior to the start time. To avoid spurious STP violations, we temporarily
622623
// set the current time back by the STA offset.
623-
env->current_tag =
624-
(tag_t){.time = effective_start_tag.time - lf_fed_STA_offset, .microstep = effective_start_tag.microstep};
625-
624+
env->current_tag.time -= lf_fed_STA_offset;
626625
LF_PRINT_LOG("Waiting for start time " PRINTF_TIME " plus STA " PRINTF_TIME ".", start_time, lf_fed_STA_offset);
627626
#else
628627
// For other than federated decentralized execution, there is no lf_fed_STA_offset variable defined.
@@ -674,7 +673,7 @@ void _lf_initialize_start_tag(environment_t* env) {
674673
// from exceeding the timestamp of the message. It will remove that barrier
675674
// once the complete message has been read. Here, we wait for that barrier
676675
// to be removed, if appropriate before proceeding to executing tag (0,0).
677-
_lf_wait_on_tag_barrier(env, (tag_t){.time = start_time, .microstep = 0});
676+
_lf_wait_on_tag_barrier(env, effective_start_tag);
678677
lf_spawn_staa_thread();
679678

680679
#else // NOT FEDERATED_DECENTRALIZED

include/core/tracepoint.h

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ typedef enum {
9999
receive_ADR_AD,
100100
receive_ADR_QR,
101101
receive_UNIDENTIFIED,
102+
send_STOP,
103+
receive_STOP,
102104
NUM_EVENT_TYPES
103105
} trace_event_t;
104106

@@ -110,63 +112,20 @@ typedef enum {
110112
* String description of event types.
111113
*/
112114
static const char* trace_event_names[] = {
113-
"Reaction starts",
114-
"Reaction ends",
115-
"Reaction deadline missed",
116-
"Schedule called",
117-
"User-defined event",
118-
"User-defined valued event",
119-
"Worker wait starts",
120-
"Worker wait ends",
121-
"Scheduler advancing time starts",
122-
"Scheduler advancing time ends",
123-
"Federated marker",
115+
"Reaction starts", "Reaction ends", "Reaction deadline missed", "Schedule called", "User-defined event",
116+
"User-defined valued event", "Worker wait starts", "Worker wait ends", "Scheduler advancing time starts",
117+
"Scheduler advancing time ends", "Federated marker",
124118
// Sending messages
125-
"Sending ACK",
126-
"Sending FAILED",
127-
"Sending TIMESTAMP",
128-
"Sending NET",
129-
"Sending LTC",
130-
"Sending STOP_REQ",
131-
"Sending STOP_REQ_REP",
132-
"Sending STOP_GRN",
133-
"Sending FED_ID",
134-
"Sending PTAG",
135-
"Sending TAG",
136-
"Sending REJECT",
137-
"Sending RESIGN",
138-
"Sending PORT_ABS",
139-
"Sending CLOSE_RQ",
140-
"Sending TAGGED_MSG",
141-
"Sending P2P_TAGGED_MSG",
142-
"Sending MSG",
143-
"Sending P2P_MSG",
144-
"Sending ADR_AD",
145-
"Sending ADR_QR",
119+
"Sending ACK", "Sending FAILED", "Sending TIMESTAMP", "Sending NET", "Sending LTC", "Sending STOP_REQ",
120+
"Sending STOP_REQ_REP", "Sending STOP_GRN", "Sending FED_ID", "Sending PTAG", "Sending TAG", "Sending REJECT",
121+
"Sending RESIGN", "Sending PORT_ABS", "Sending CLOSE_RQ", "Sending TAGGED_MSG", "Sending P2P_TAGGED_MSG",
122+
"Sending MSG", "Sending P2P_MSG", "Sending ADR_AD", "Sending ADR_QR",
146123
// Receiving messages
147-
"Receiving ACK",
148-
"Receiving FAILED",
149-
"Receiving TIMESTAMP",
150-
"Receiving NET",
151-
"Receiving LTC",
152-
"Receiving STOP_REQ",
153-
"Receiving STOP_REQ_REP",
154-
"Receiving STOP_GRN",
155-
"Receiving FED_ID",
156-
"Receiving PTAG",
157-
"Receiving TAG",
158-
"Receiving REJECT",
159-
"Receiving RESIGN",
160-
"Receiving PORT_ABS",
161-
"Receiving CLOSE_RQ",
162-
"Receiving TAGGED_MSG",
163-
"Receiving P2P_TAGGED_MSG",
164-
"Receiving MSG",
165-
"Receiving P2P_MSG",
166-
"Receiving ADR_AD",
167-
"Receiving ADR_QR",
168-
"Receiving UNIDENTIFIED",
169-
};
124+
"Receiving ACK", "Receiving FAILED", "Receiving TIMESTAMP", "Receiving NET", "Receiving LTC", "Receiving STOP_REQ",
125+
"Receiving STOP_REQ_REP", "Receiving STOP_GRN", "Receiving FED_ID", "Receiving PTAG", "Receiving TAG",
126+
"Receiving REJECT", "Receiving RESIGN", "Receiving PORT_ABS", "Receiving CLOSE_RQ", "Receiving TAGGED_MSG",
127+
"Receiving P2P_TAGGED_MSG", "Receiving MSG", "Receiving P2P_MSG", "Receiving ADR_AD", "Receiving ADR_QR",
128+
"Receiving UNIDENTIFIED", "Sending STOP", "Receiving STOP"};
170129

171130
/**
172131
* @brief A trace record that gets written in binary to the trace file in the default implementation.

0 commit comments

Comments
 (0)