Jelajahi Sumber

modules_k/pua: transaction not ended before calling send_publish() from TM call-back

- Found by Hugh Waite @ Crocodile RCS and fixed by Peter Dunkley
  @ Crocodile RCS
Peter Dunkley 13 tahun lalu
induk
melakukan
b9e77beaee
1 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 13 1
      modules_k/pua/send_publish.c

+ 13 - 1
modules_k/pua/send_publish.c

@@ -207,6 +207,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	db1_res_t *res=NULL;
 	ua_pres_t dbpres;
 	str pres_uri={0,0}, watcher_uri={0,0}, extra_headers={0,0};
+	int end_transaction = 1;
 
 	memset(&dbpres, 0, sizeof(dbpres));
 	dbpres.pres_uri = &pres_uri;
@@ -275,6 +276,17 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 			publ.extra_headers= hentity->extra_headers;
 			publ.cb_param= hentity->cb_param;
 
+			if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
+			{
+				if (pua_dbf.end_transaction(pua_db) < 0)
+				{
+					LM_ERR("in end_transaction\n");
+					goto error;
+				}
+			}
+
+			end_transaction = 0;
+
 			if(send_publish(&publ)< 0)
 			{
 				LM_ERR("when trying to send PUBLISH\n");
@@ -432,7 +444,7 @@ done:
 
 	if (res) free_results_puadb(res);
 
-	if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
+	if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction && end_transaction)
 	{
 		if (pua_dbf.end_transaction(pua_db) < 0)
 		{