Handle multiple RTR connections in same thread
Instead of creating a separate thread for every rtr connection it's more efficient to switch to an async event-based approach to handle multiple connections from the same thread. This could be done with the help of libevent
I would vote for just adding select() calls.
I just gave it another thought. Since there is already a system in place that divides the RTR manager into groups containing sockets, the groups would be perfect for spawning one thread each that uses select() on its own sockets.
Yes, using select() could also be sufficient. I would vote for only one thread that handles all connections including multiple manager group, it doesn't provide a benefit to have a thread for each manager group. The threads have probably only a very low load also on older CPUs
In this case, the manager would have to collect all sockets from all groups, which would break separation of concerns, locality and modularity. On each return from select(), it would again have to check all sockets in all groups using FD_ISSET() etc. If the groups have been designed to manage their sockets like a black box, the manager shouldn't interfere here.
Also, having each group spawn its own thread has the advantage that thread priorities can be assigned according to the group's preference value, helping higher-priority groups' socket data to be read earlier, especially when multiple NICs are used. Users can design their RTR manager groups accordingly in this case, without having to resort to maintaining multiple RTR managers.