[Freeswitch-dev] Can someone explain this block of code to me re: OPTIONS pings and timing

Darren Schreiber d at d-man.org
Wed Jul 11 09:33:23 MSD 2012


Hi all,
We are seeing a situation on all of our FreeSWITCH instances where OPTIONS pings are happening at an interval of about 45 seconds. I was expecting these to fire roughly every 30.

I looked at sofia_reg.c to see when sofia_reg_nat_callback() gets kicked off and it's fired from within the sofia_reg_check_expire, which is fired from within the sofia_profile_worker_thread_run() thread.

If I'm understanding the loop inside the sofia profile worker thread correctly, it pops requests off the SQL stack to process them in batch, then runs the sofia watchdog code to see if sofia is behaving, then if the number of iterations is above IREG_SECONDS constant it fires off the registration check in the database (which also kicks off options pings). IREG_SECONDS seems to be set at 30…

mod_sofia.h:
#define IREG_SECONDS 30

The word "seconds" would make me think it should fire reliably every +/- 30 seconds. But it's firing every 45. The system isn't really that busy otherwise IMHO. So I am perplexed if the math is just wrong in this loop or if I'm misunderstanding this code.

I'm trying to figure out how the timer is counted, looks like it's tied to the microseconds of the current clock so this should be pretty accurate, busy or not busy:

                                switch_interval_time_t sleepy_time = !statements ? 1000000 : switch_micro_time_now() - last_commit - profile->trans_timeout*1000;

                                if (sleepy_time < 1000 || sleepy_time > 1000000) {
                                        sleepy_time = 1000;
                                }


What am I missing here…? Just looking for root cause possibilities, happy to poke around at some settings before mucking up the code with debug statements and the like…

- Darren Schreiber

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20120710/0ddd25f4/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list