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
_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Reply via email to