Module: kamailio
Branch: master
Commit: bbb869441feb141d6732926973a6a95224d70a17
URL:
https://github.com/kamailio/kamailio/commit/bbb869441feb141d6732926973a6a95…
Author: Victor Seva <vseva(a)sipwise.com>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2024-08-27T10:12:58+02:00
pua: get_record_puadb() add pres_uri to the query
if pres_uri is present, added to the query to avoid this kind of
errors:
pua [pua_db.c:895]: get_record_puadb(): Too many rows
found (2)
Since there's always in our case two records with the same pres_id
(callee|caller):
| 27 | sip:testgroup1010@invite-group-parallel.scenarios-pbx.test |
DIALOG_PUBLISH.padi-66c6f28a-108ad-4 | 32 | 1724318050 | 1724338210 | 1024 |
a.1724314250.67760.9.0 |
| 29 | sip:testuser1003@invite-group-parallel.scenarios-pbx.test |
DIALOG_PUBLISH.padi-66c6f28a-108ad-4 | 32 | 1724318050 | 1724338210 | 1024 |
a.1724314250.67757.8.0 |
---
Modified: src/modules/pua/pua_db.c
Modified: src/modules/pua/pua_db.h
Modified: src/modules/pua/send_publish.c
---
Diff:
https://github.com/kamailio/kamailio/commit/bbb869441feb141d6732926973a6a95…
Patch:
https://github.com/kamailio/kamailio/commit/bbb869441feb141d6732926973a6a95…
---
diff --git a/src/modules/pua/pua_db.c b/src/modules/pua/pua_db.c
index f66c3b210f7..67f02736836 100644
--- a/src/modules/pua/pua_db.c
+++ b/src/modules/pua/pua_db.c
@@ -2,6 +2,7 @@
* pua db - presence user agent database support
*
* Copyright (C) 2011 Crocodile RCS Ltd
+ * Copyright (C) 2024 Victor Seva (Sipwise)
*
* This file is part of Kamailio, a free SIP server.
*
@@ -790,17 +791,26 @@ int insert_record_puadb(ua_pres_t *pres)
/******************************************************************************/
-ua_pres_t *get_record_puadb(
- str pres_id, str *etag, ua_pres_t *result, db1_res_t **dbres)
+ua_pres_t *get_record_puadb(str *pres_uri, str pres_id, str *etag,
+ ua_pres_t *result, db1_res_t **dbres)
{
- db_key_t q_cols[2];
- db_val_t q_vals[2], *values;
+ db_key_t q_cols[3];
+ db_val_t q_vals[3], *values;
db_row_t *rows;
db1_res_t *res;
int n_query_cols = 0, nr_rows;
db_query_f query_fn =
pua_dbf.query_lock ? pua_dbf.query_lock : pua_dbf.query;
+ if(pres_uri != NULL) {
+ q_cols[n_query_cols] = &str_pres_uri_col;
+ q_vals[n_query_cols].type = DB1_STR;
+ q_vals[n_query_cols].nul = 0;
+ q_vals[n_query_cols].val.str_val.s = pres_uri->s;
+ q_vals[n_query_cols].val.str_val.len = pres_uri->len;
+ n_query_cols++;
+ }
+
q_cols[n_query_cols] = &str_pres_id_col;
q_vals[n_query_cols].type = DB1_STR;
q_vals[n_query_cols].nul = 0;
diff --git a/src/modules/pua/pua_db.h b/src/modules/pua/pua_db.h
index 788d1656207..cd448b0467d 100644
--- a/src/modules/pua/pua_db.h
+++ b/src/modules/pua/pua_db.h
@@ -2,6 +2,7 @@
* pua_db headers - presence user agent db headers
*
* Copyright (C) 2011 Crocodile RCS Ltd
+ * Copyright (C) 2024 Victor Seva (Sipwise)
*
* This file is part of Kamailio, a free SIP server.
*
@@ -58,8 +59,8 @@ int update_dialog_puadb(ua_pres_t *pres, int expires, str *contact);
list_entry_t *get_subs_list_puadb(str *did);
int insert_record_puadb(ua_pres_t *pres);
-ua_pres_t *get_record_puadb(
- str pres_id, str *etag, ua_pres_t *result, db1_res_t **res);
+ua_pres_t *get_record_puadb(str *pres_uri, str pres_id, str *etag,
+ ua_pres_t *result, db1_res_t **res);
int delete_record_puadb(ua_pres_t *pres);
int update_record_puadb(ua_pres_t *pres, int expires, str *contact);
int update_version_puadb(ua_pres_t *pres);
diff --git a/src/modules/pua/send_publish.c b/src/modules/pua/send_publish.c
index 53644265633..4a06870f7a5 100644
--- a/src/modules/pua/send_publish.c
+++ b/src/modules/pua/send_publish.c
@@ -309,7 +309,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params
*ps)
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(
+ } else if((db_presentity = get_record_puadb(hentity->pres_uri,
hentity->id, &hentity->etag, &dbpres, &res))
!= NULL) {
update_record_puadb(hentity, lexpire, &etag);
@@ -468,7 +468,8 @@ int send_publish(publ_info_t *publ)
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);
+ presentity = get_record_puadb(
+ publ->pres_uri, publ->id, publ->etag, &dbpres, &res);
} else {
ua_pres_t pres;