Skip to content

Commit

Permalink
modules/pua: db_mode=2 send_publish fixes
Browse files Browse the repository at this point in the history
- plus small debug message edits
  • Loading branch information
juha-h committed Oct 12, 2014
1 parent 214b161 commit 6822ff4
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions modules/pua/send_publish.c
Expand Up @@ -333,22 +333,23 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
etag= hdr->body;

LM_DBG("completed with status %d [contact:%.*s]\n",
ps->code, hentity->pres_uri->len, hentity->pres_uri->s);
ps->code, hentity->pres_uri->len, hentity->pres_uri->s);

if (lexpire == 0)
{
find_and_delete_record(hentity, hash_code);
goto done;
}

if (pua_dbf.affected_rows != NULL || dbmode != PUA_DB_ONLY)
{
if (find_and_update_record(hentity, hash_code, lexpire, &etag) > 0)
goto done;
}
else
{
if ((db_presentity = get_record_puadb(hentity->id, &hentity->etag, &dbpres, &res)) != NULL)
if (hentity->etag.s) {
if (pua_dbf.affected_rows != NULL || dbmode != PUA_DB_ONLY) {
if (find_and_update_record(hentity, hash_code,
lexpire, &etag) > 0)
goto done;
}
else if ((db_presentity =
get_record_puadb(hentity->id, &hentity->etag,
&dbpres, &res)) != NULL)
{
update_record_puadb(hentity, lexpire, &etag);
goto done;
Expand Down Expand Up @@ -426,7 +427,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
insert_htable(presentity, hash_code);
lock_release(&HashT->p_records[hash_code].lock);
}
LM_DBG("***Inserted in hash table\n");
LM_DBG("Inserted record\n");

done:
if(hentity->ua_flag == REQ_OTHER)
Expand Down Expand Up @@ -517,11 +518,14 @@ int send_publish( publ_info_t* publ )

if (dbmode==PUA_DB_ONLY)
{
memset(&dbpres, 0, sizeof(dbpres));
dbpres.pres_uri = &pres_uri;
dbpres.watcher_uri = &watcher_uri;
dbpres.extra_headers = &extra_headers;
presentity = get_record_puadb(publ->id, publ->etag, &dbpres, &res);
if (publ->etag) {
memset(&dbpres, 0, sizeof(dbpres));
dbpres.pres_uri = &pres_uri;
dbpres.watcher_uri = &watcher_uri;
dbpres.extra_headers = &extra_headers;
presentity = get_record_puadb(publ->id, publ->etag,
&dbpres, &res);
}
}
else
{
Expand Down Expand Up @@ -582,7 +586,7 @@ int send_publish( publ_info_t* publ )
}
else
{
LM_DBG("record found in hash_table\n");
LM_DBG("record found\n");
publ->flag= UPDATE_TYPE;
etag.s= (char*)pkg_malloc(presentity->etag.len* sizeof(char));
if(etag.s== NULL)
Expand Down

0 comments on commit 6822ff4

Please sign in to comment.