<p>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).</p>

<p>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.</p>

<p>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.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/pull/429#issuecomment-172890382">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZV5ggDa9F75dFKfWk0tdMfdMN2b3ks5pbk9bgaJpZM4Guvjo.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/pull/429#issuecomment-172890382"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>