[sr-dev] git:4.2: modules/pua: db_mode=2 send_publish fixes

Juha Heinanen jh at tutpro.com
Sun Oct 12 12:43:48 CEST 2014


Module: sip-router
Branch: 4.2
Commit: 65659addafd0a492cafbb6c9cbaf3644442f333a
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=65659addafd0a492cafbb6c9cbaf3644442f333a

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Sun Oct 12 13:41:41 2014 +0300

modules/pua: db_mode=2 send_publish fixes

- plus small debug message edits
(cherry picked from commit 6822ff45e931ad3e93b22ebf7d1beb350bf27e70)

---

 modules/pua/send_publish.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/modules/pua/send_publish.c b/modules/pua/send_publish.c
index 27cfbd0..da74ab7 100644
--- a/modules/pua/send_publish.c
+++ b/modules/pua/send_publish.c
@@ -333,7 +333,7 @@ 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)
 	{
@@ -341,14 +341,15 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 		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;
@@ -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)
@@ -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
 	{
@@ -582,7 +586,7 @@ insert:
 	}
 	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)




More information about the sr-dev mailing list