From 07119ef9de4a63240a408ed1a32c48990a62a788 Mon Sep 17 00:00:00 2001 From: Dongha Kim <74869052+Jakio815@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:45:25 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Edward A. Lee --- core/federated/RTI/rti_remote.c | 22 +++++-------------- .../core/federated/network/socket_common.h | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/core/federated/RTI/rti_remote.c b/core/federated/RTI/rti_remote.c index ef6478ab3..a6ef46307 100644 --- a/core/federated/RTI/rti_remote.c +++ b/core/federated/RTI/rti_remote.c @@ -1583,23 +1583,11 @@ void initialize_RTI(rti_remote_t* rti) { rti_remote->num_feds_proposed_start = 0; rti_remote->all_federates_exited = false; rti_remote->federation_id = "Unidentified Federation"; - // The federate and RTI both initialize the user_specified_port as 0. For the RTI, when the user_specified_port is 0, - // it recognizes that there was no user input to assign a port and assigns the port to the DEFAULT_PORT, which is - // 15045. - - // For the federate, when the user_specified_port is 0, it also recognizes that there was no user input and makes the - // OS assign the port. - - // The create_TCP_server gets this input argument port, which is actually the user_specified_port for both RTI and - // federate. To distinguish whether the RTI or federate is calling this function, I changed the initial value of the - // RTI's port as 1. - - // We need to distinguish whether the RTI or federate called the create_TCP_server function for two reasons. - - // First, we should set the default port, which RTI and federate differ. - // Next, RTI increments the port number starting from 15045, when the port binding fails. However, the federate does - // not increment the port number and try binding. - // For more info, check this pr. https://github.com/lf-lang/reactor-c/pull/505 + // Default values for user_specified_port are 0 for a federate and 1 for the RTI. Neither of these are valid port + // numbers, but rather specify that an available port needs to be found. With value 0, the operating system will + // provide an available port number. With value 1, the function will first try DEFAULT_PORT, which is 15045, and, + // if this fails, wait for time given by PORT_BIND_RETRY_INTERVAL and try again. It fails if this process fails after + // MAX_NUM_PORT_ADDRESSES tries. For more details, check this PR. https://github.com/lf-lang/reactor-c/pull/505. rti_remote->user_specified_port = 1; rti_remote->final_port_TCP = 0; rti_remote->socket_descriptor_TCP = -1; diff --git a/include/core/federated/network/socket_common.h b/include/core/federated/network/socket_common.h index 37bf14f48..9c088becf 100644 --- a/include/core/federated/network/socket_common.h +++ b/include/core/federated/network/socket_common.h @@ -24,7 +24,7 @@ /** * Bound on the number of retries to connect to the RTI. - * A federate will retry every CONNECT_RETRY_INTERVAL seconds until + * A federate will retry every CONNECT_RETRY_INTERVAL nanoseconds until * CONNECTION_TIMEOUT expires. */ #define CONNECT_TIMEOUT MINUTES(1)