Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakio815 committed Dec 21, 2024
1 parent 9fb6f63 commit a9291bd
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions core/federated/federate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,26 +1778,27 @@ void lf_connect_to_federate(uint16_t remote_federate_id) {
return;
}

// Check whether the RTI is still there.
if (rti_failed())
break;
// Check whether the RTI is still there.
if (rti_failed())
break;

// Wait ADDRESS_QUERY_RETRY_INTERVAL nanoseconds.
lf_sleep(ADDRESS_QUERY_RETRY_INTERVAL);
} else {
// Connect was successful.
size_t buffer_length = 1 + sizeof(uint16_t) + 1;
unsigned char buffer[buffer_length];
buffer[0] = MSG_TYPE_P2P_SENDING_FED_ID;
if (_lf_my_fed_id == UINT16_MAX) {
// This error is very unlikely to occur.
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX -1);
}
encode_uint16((uint16_t)_lf_my_fed_id, (unsigned char*)&(buffer[1]));
unsigned char federation_id_length = (unsigned char)strnlen(federation_metadata.federation_id, 255);
buffer[sizeof(uint16_t) + 1] = federation_id_length;
// Trace the event when tracing is enabled
tracepoint_federate_to_federate(send_FED_ID, _lf_my_fed_id, remote_federate_id, NULL);
// Wait ADDRESS_QUERY_RETRY_INTERVAL nanoseconds.
lf_sleep(ADDRESS_QUERY_RETRY_INTERVAL);
}
else {
// Connect was successful.
size_t buffer_length = 1 + sizeof(uint16_t) + 1;
unsigned char buffer[buffer_length];
buffer[0] = MSG_TYPE_P2P_SENDING_FED_ID;
if (_lf_my_fed_id == UINT16_MAX) {
// This error is very unlikely to occur.
lf_print_error_and_exit("Too many federates! More than %d.", UINT16_MAX - 1);
}
encode_uint16((uint16_t)_lf_my_fed_id, (unsigned char*)&(buffer[1]));
unsigned char federation_id_length = (unsigned char)strnlen(federation_metadata.federation_id, 255);
buffer[sizeof(uint16_t) + 1] = federation_id_length;
// Trace the event when tracing is enabled
tracepoint_federate_to_federate(send_FED_ID, _lf_my_fed_id, remote_federate_id, NULL);

// No need for a mutex because we have the only handle on the socket.
write_to_socket_fail_on_error(&socket_id, buffer_length, buffer, NULL, "Failed to send fed_id to federate %d.",
Expand Down

0 comments on commit a9291bd

Please sign in to comment.