Skip to content

Commit

Permalink
[usrloc] fix contact removal in DB_ONLY mode
Browse files Browse the repository at this point in the history
(cherry picked from commit b807576180ef4ae0e85176bab364703f4af5b419)
  • Loading branch information
ionutrazvanionita committed Apr 26, 2017
1 parent afeca1e commit f114dd2
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion modules/usrloc/urecord.c
Expand Up @@ -384,6 +384,33 @@ static inline int wb_timer(urecord_t* _r,query_list_t **ins_list)
return ins_done;
}

static inline int db_only_wb_timer(urecord_t* _r) {

if (db_mode != DB_ONLY)
return 0;

if (!_r) {
LM_ERR("no urecord!\n");
return -1;
}

if (wb_timer(_r, 0) < 0) {
LM_ERR("failed to sync with db\n");
return -1;
}

/* delete all the contacts left pending in the "to-be-delete" buffer */
if (cid_len &&
db_multiple_ucontact_delete(_r->domain, cid_keys, cid_vals, cid_len) < 0) {
LM_ERR("failed to delete contacts from database\n");
return -1;
}

return 0;
}





int timer_urecord(urecord_t* _r,query_list_t **ins_list)
Expand Down Expand Up @@ -450,7 +477,7 @@ void release_urecord(urecord_t* _r, char is_replicated)
{
if (db_mode==DB_ONLY) {
/* force flushing to DB*/
if (wb_timer(_r, 0) < 0)
if (db_only_wb_timer(_r) < 0)
LM_ERR("failed to sync with db\n");
/* now simply free everything */
free_urecord(_r);
Expand Down Expand Up @@ -533,6 +560,12 @@ int delete_ucontact(urecord_t* _r, struct ucontact* _c, char is_replicated)
}

mem_delete_ucontact(_r, _c);

if (db_mode == DB_ONLY) {
/* force flushing to DB*/
if (db_only_wb_timer(_r) < 0)
LM_ERR("failed to sync with db\n");
}
}

return 0;
Expand Down

0 comments on commit f114dd2

Please sign in to comment.