[OpenSIPS-Devel] [opensips] Proposed fix for erratic nat_traversal keepalives (#751)

Bogdan Andrei IANCU notifications at github.com
Wed Jan 13 12:16:08 CET 2016


Hi,

@saghul , @aerringer is indeed right - I wasn;t paying too much attached to the inners of the timer routing. But starting with 2.1, there is no such concept as timer process. The timer routines are executed in any (ballanced) opensips process (worker). So using static vars between the calls of your timer routine is broken now.

The solution proposed by @aerringer is ok (to move the counter in shared memory, so it is accessible  from any process - depending on where the timer job is executed). 
Another solution, much simpler (no shm mem or locking involved), is how the nathelper module does (in order to accomplish the partitioning of the pingings). It simply registers the timer routing multiple times, with different parameters, where the param value consists of all possible values of the iterator (from 1 to keepalive_interval, in your case). See:
  https://github.com/OpenSIPS/opensips/blob/2.1/modules/nathelper/nathelper.c#L552

@aerringer , some interesting for you, that may simplify your patch a lot - the nat_helper timer routing is registered with "TIMER_FLAG_DELAY_ON_DELAY" - this guarantees that (even executed in various processes) the handler will not be run in parallel (all its executions will be serial). So you do not need locking at all. Also, the counter itself can shm allocated and its pointer can be passed to the timer handler (more elegant versus a global var).

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/751#issuecomment-171257486
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20160113/b4c3216c/attachment.htm>


More information about the Devel mailing list