فهرست منبع

modules/pua: db_mode=2 send_publish fixes

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

(cherry picked from commit 65659addafd0a492cafbb6c9cbaf3644442f333a)
(cherry picked from commit f68b6a9c4860298c0bf17f1943f5fc4226650f9f)
Juha Heinanen 11 سال پیش
والد
کامیت
6860b38d3c
1فایلهای تغییر یافته به همراه20 افزوده شده و 16 حذف شده
  1. 20 16
      modules/pua/send_publish.c

+ 20 - 16
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)