2
0
Эх сурвалжийг харах

modules/pua: db_mode=2 send_publish fixes

- plus small debug message edits
Juha Heinanen 11 жил өмнө
parent
commit
6822ff45e9
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)