[sr-dev] usrloc db_mode == DB_ONLY and callbacks
Daniel-Constantin Mierla
miconda at gmail.com
Thu May 21 13:43:33 CEST 2015
Hello,
indeed, it seems the callbacks are called early for db only mode -- you
can push a fix for it if you get the time.
Cheers,
Daniel
On 21/05/15 13:07, Victor Seva wrote:
> Hi,
>
> I just notice an error in pua_reginfo and I was intrigued:
>
> a REGISTER is received and then:
>
>> proxy[30664]: DEBUG: usrloc [udomain.c:602]: db_load_urecord(): aor 88835677220000 at X.X.X.X not found in table location
>> proxy[30664]: DEBUG: usrloc [ul_callback.h:89]: run_ul_callbacks(): contact=0x7fddc7836b40, callback type 1/1, id 0 entered
>> proxy[30664]: DEBUG: pua_reginfo [usrloc_cb.c:240]: reginfo_usrloc_cb(): AOR: 88835677220000 at X.X.X.X (location)
>> proxy[30664]: DEBUG: pua_reginfo [usrloc_cb.c:241]: reginfo_usrloc_cb(): type= UL_CONTACT_INSERT
>> proxy[30664]: DEBUG: usrloc [udomain.c:702]: db_load_urecord_by_ruid(): aor uloc-555da99c-77c8-1 not found in table location
>> proxy[30664]: ERROR: pua_reginfo [usrloc_cb.c:261]: reginfo_usrloc_cb(): '88835677220000 at X.X.X.X (location)' Not found in usrloc
> So I took a look over usrloc and I found that the callbacks are been
> called after insert in mem but before insert on DB
> when you set DB_ONLY.
>
>> int insert_ucontact(urecord_t* _r, str* _contact, ucontact_info_t* _ci, ucontact_t** _c)
>> {
>> if ( ((*_c)=mem_insert_ucontact(_r, _contact, _ci)) == 0) {
>> LM_ERR("failed to insert contact\n");
>> return -1;
>> }
>>
>> if (exists_ulcb_type(UL_CONTACT_INSERT)) {
>> run_ul_callbacks( UL_CONTACT_INSERT, *_c);
>> }
>>
>> if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) {
>> if (db_insert_ucontact(*_c) < 0) {
>> LM_ERR("failed to insert in database\n");
>> return -1;
>> } else {
>> (*_c)->state = CS_SYNC;
>> }
>> }
>>
>> return 0;
>> }
> This happens on update too:
>
>> int update_ucontact(struct urecord* _r, ucontact_t* _c, ucontact_info_t* _ci)
>> {
>> int res;
>>
>> /* we have to update memory in any case, but database directly
>> * only in db_mode 1 */
>> if (mem_update_ucontact( _c, _ci) < 0) {
>> LM_ERR("failed to update memory\n");
>> return -1;
>> }
>>
>> /* run callbacks for UPDATE event */
>> if (exists_ulcb_type(UL_CONTACT_UPDATE))
>> {
>> LM_DBG("exists callback for type= UL_CONTACT_UPDATE\n");
>> run_ul_callbacks( UL_CONTACT_UPDATE, _c);
>> }
>>
>> if (_r && db_mode!=DB_ONLY)
>> update_contact_pos( _r, _c);
>>
>> st_update_ucontact(_c);
>>
>> if (db_mode == WRITE_THROUGH || db_mode==DB_ONLY) {
>> if (ul_db_update_as_insert)
>> res = db_insert_ucontact(_c);
>> else
>> res = db_update_ucontact(_c);
>>
>> if (res < 0) {
>> LM_ERR("failed to update database\n");
>> return -1;
>> } else {
>> _c->state = CS_SYNC;
>> }
>> }
>> return 0;
>> }
> So I would say that DB_ONLY should be honored here before calling the
> callbacks
>
>
>
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20150521/90093ec0/attachment.html>
More information about the sr-dev
mailing list