Skip to content

Conversation

@rolysr
Copy link
Collaborator

@rolysr rolysr commented Oct 29, 2025

Previous version of the master to metalogger service communication was using an old C-styled code, which made this implementation hard to maintain and understand. Also, previous manual memory assigment and free was performed manually, which is an error-prone approach. This commit modernizes the master to metaloggers service by moving to a C++-style based code.

@rolysr rolysr force-pushed the refactor-matoml-code branch 3 times, most recently from da49791 to c76da6d Compare October 30, 2025 00:40
@rolysr rolysr self-assigned this Oct 30, 2025
@rolysr rolysr force-pushed the refactor-matoml-code branch 2 times, most recently from 48ebf31 to c821dc8 Compare October 30, 2025 15:32
@rolysr rolysr marked this pull request as ready for review October 30, 2025 18:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the matomlserv.cc file by refactoring it from C-style code to modern C++. The changes replace manual memory management with RAII patterns, use STL containers instead of raw pointers and manual linked lists, and adopt modern C++ conventions throughout.

Key changes include:

  • Replaced manual memory management and linked lists with std::deque, std::queue, and std::vector
  • Introduced InputPacket and OutputPacket wrapper classes for safer packet handling
  • Converted C-style strings to std::string and enums to enum class
  • Modernized logging from safs_pretty_syslog to safs::log_* functions
  • Replaced macros with constexpr constants

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rolysr
Copy link
Collaborator Author

rolysr commented Oct 30, 2025

@gemini-code-assist review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is an excellent step towards modernizing the master-metalogger communication service. The transition from C-style manual memory management to C++ containers like std::deque, std::vector, and std::string greatly improves code readability, maintainability, and safety by leveraging RAII. The use of enum class and constexpr is also a welcome improvement.

While the refactoring is very well done, I've identified a critical issue where a cleanup function is not called, leading to resource leaks and potential dangling pointers. I've also found a few minor issues related to incorrect logging format strings and a degradation in error reporting. My detailed comments are below.

@rolysr rolysr force-pushed the refactor-matoml-code branch from c821dc8 to 2b1b5a8 Compare October 31, 2025 12:03
Copy link
Contributor

@lgsilva3087 lgsilva3087 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is looking great. Please see my comments.

@rolysr rolysr force-pushed the refactor-matoml-code branch from 2b1b5a8 to 2a50605 Compare November 3, 2025 11:09
Previous version of the master to metalogger service communication was
using an old C-styled code, which made this implementation hard to
maintain and understand. Also, previous manual memory assigment and free
was performed manually, which is an error-prone approach. This commit
modernizes the master to metaloggers service by moving to a C++-style
based code.

Signed-off-by: Rolando Sánchez Ramos <[email protected]>
@rolysr rolysr force-pushed the refactor-matoml-code branch from 2a50605 to 1d87fec Compare November 3, 2025 11:17
Copy link
Contributor

@lgsilva3087 lgsilva3087 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great job.

@rolysr rolysr merged commit 4c649af into dev Nov 3, 2025
9 checks passed
@rolysr rolysr deleted the refactor-matoml-code branch November 3, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants