[Freeswitch-dev] Registration Expiration Problem with NATHACK
Jonathan Palley
jpalley at gmail.com
Mon Apr 14 09:51:01 EDT 2008
Hi -
There is a small bug with registration expiration and nathack.
There is an easy fix but the behavior is unexpected and I believe
there is a chance it may point to a larger problem.
So, I bring it up here. The bug:
sofia_reg.c has the function sofia_reg_check_expire which is called
once a minute to clean out expired registrations from the database.
On line 263: switch_snprintf(sql, sizeof(sql), "delete from
sip_registrations where expires > 0 and expires <= %ld", (long) now);
It deletes expired registrations.
Later in the function we search for NATHACK user agents to send them
an OPTIONS for the NAT keep alive.
Line 282: switch_snprintf(sql, sizeof(sql), "select * from
sip_registrations where status like '%%NATHACK%%'");
Here's the BUG: Line 282 selects records in the database that are
supposed to be deleted in 263. This means you send NAT keep alive to
agents that have already expired. The registrations are then cleared
out of the db once this function completes. Clearly there is some
sort of lock around the db that prevents the delete from occurring
when the sql function is actually called.
Now, we can solve the immediate bug by changing the SQL statement in
Line 282 to not select expired registrations...but is the sqlite
supposed to lock like this?
Thanks -
JP
More information about the Freeswitch-dev
mailing list