[Kamailio-Devel] SF.net SVN: openser:[5771] trunk/modules/pua_usrloc/ul_publish.c
Iñaki Baz Castillo
ibc at aliax.net
Fri Mar 27 02:02:01 CET 2009
El Viernes 27 Marzo 2009, Inaki Baz Castillo escribió:
> An error occurs if Kamailio was restarted/stopped and for any reason
> couldn't store a pua entry in 'pua' DB table. It can also occur if 'pua'
> table is cleaned externally while Kamailio is stopped so cannot retrieve
> these entries from DB when restarting. In these cases, when a refresh
> registration for that user creates an UPDATE action in pua_usrloc, pua
> 'ul_publish()' would fail since the appropiate entry doesn't exist in pua
> hast table ("New PUBLISH and no body found - invalid request").
> This code solves this problem by invoking an INSERT action if an UPDATE
> action failed due to the above error. It will however generate a new
> presentity entry in the presence server (until the previous one expires),
> but this is a minor issue.
I'd like also to explain how I've checked it:
Using a script I send a REGISTER to Kamailio and run "pua_set_publish()".
pua_usrloc receives an INSERT callback action and creates a PUBLISH with XML
body (status "open").
Later I send more REGISTER's periodically, incrementing CSeq in each one, but
keeping the Call-ID. In this way, the registrar module updates the location
table for this AoR and "pua_set_publish()" receives an UPDATE action callback.
This UPDATE action just will generate a proper PUBLISH if pua modules already
contains in memory a pua entry for that AoR (it does thanks to the above first
REGISTER), so the generated PUBLISH will contain no body, but the SIP-If-Match
header mathing the SIP-ETag received in the 200 for the first PUBLISH. This
will update the expiration time in the presence server.
Now I stop Kamailio so pua module dumps to pua DB table all the pua hash
table, and expects to retrieve them from the table when restarting again. But
I delete an entry in pua table before starting again Kamailio. Then Kamailio
cannot retrieve it.
Later I send a new REGISTER (CSeq + 1). Registrar module will generate an
UPDATE callback in pua_usrloc since the registration updates an existing one.
So pua_usrloc sends a PUBLISH with no body to pua module but pua module
doesn't contain an entry for it, so it cannot set the SIP-If-Match header (and
returns error: "New PUBLISH and no body found - invalid request").
My code reacts on that error so when it occurs, pua_usrloc acts as if it
received an INSERT callback from usrloc instead of an UPDATE callback. In this
way it generates a new PUBLISH (with XML body: status "open").
In my tests it works well. Hope it's useful.
--
Iñaki Baz Castillo <ibc at aliax.net>
More information about the Devel
mailing list