Closed byeonggiljun closed 4 months ago
Recent updates in the core/federated/RTI/rti_remote.c
and core/utils/pqueue_tag.c
files include thread synchronization and memory management enhancements. Specifically, adjustments were made to thread joining and deallocation processes, and a new function call was employed to manage priority queue operations, thereby ensuring more robust and efficient execution flow.
File | Change Summary |
---|---|
core/federated/RTI/rti_remote.c |
Added thread join for responder_thread , set all_federates_exited to true, adjusted memory deallocation in free_scheduling_nodes , and modified its declaration. |
core/utils/pqueue_tag.c |
Replaced pqueue_tag_pop() with pqueue_tag_pop_tag() in the loop within pqueue_tag_remove_up_to to enhance priority queue operations. |
[!TIP]
Early access features: enabled
We are currently testing the following features in early access: - **OpenAI `gpt-4o` model for code reviews and chat**: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues. - OSS projects are currently opted into early access features by default.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@edwardalee?
This PR resolves memory leaks from the RTI. I attached the output file from Valgrind. valgrind-out-before.txt
With this PR, most of the leakages have disappeared.
valgrind-out-after.txt
Specifically, now the function
pqueue_tag_remove_up_to
frees dynamically allocated elements. Also, memory allocated for storing each node'supstream
andmin_delays
is explicitly freed when the RTI terminates.Valgrind reports two remaining issues. The two threads shown below are not explicitly joined. https://github.com/lf-lang/reactor-c/blob/587a8f9498b69bc82f404e432f881d7bb0bcf383/core/federated/RTI/rti_remote.c#L666
This thread is created in the function handle_stop_request_message to set a timeout to wait for
MSG_TYPE_STOP_REQUEST_REPLY
messages. Thus, this thread cannot be joined in the functionhandle_stop_request_message
and I didn't come up with joining this function.https://github.com/lf-lang/reactor-c/blob/587a8f9498b69bc82f404e432f881d7bb0bcf383/core/federated/RTI/rti_remote.c#L1677
This thread is responsible for responding to erroneous connection requests. Thus, this thread should not be joined.
Summary by CodeRabbit
Bug Fixes
responder_thread
to ensure proper synchronization.free_scheduling_nodes
.Refactor