Ah yes, good catch and good question. A quick solution would be to move
initialization of rtpp_socks out of child_init() and instead do it on demand
whenever it's needed, i.e. just before sending a request and only when
something in the list of proxies has changed (or if it hasn't been initialized
yet).
The code then just needs a way to detect changes to the lists. This can be done
for example by keeping a global running counter in shared memory (protected by
a lock) and a private per-child counter. Every time a change is made, the
global shared counter is increased by one and every time a child wants to send
a request, it compares its private counter with the shared one and if it
doesn't match, it rebuilds its rtpp_socks.
Another option would be to use pnode->idx and have each child keep the size of
its rtpp_socks array. If a child wants to send a request to a node with an idx
larger than its array size, it grows and rebuilds the rtpp_socks array as
needed. This would only catch new additions to the linked lists but no other
changes.
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/429#issuecomment-172890382
_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev