Module: kamailio
Branch: master
Commit: bd7261a5f656a8e723bb6999633c55864b46f1b6
URL:
https://github.com/kamailio/kamailio/commit/bd7261a5f656a8e723bb6999633c558…
Author: Victor Seva <vseva(a)sipwise.com>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2022-06-16T12:17:32+02:00
pua_dialoginfo: use lock when use_puburi_avps is set
---
Modified: src/modules/pua_dialoginfo/pua_dialoginfo.c
Modified: src/modules/pua_dialoginfo/pua_dialoginfo.h
---
Diff:
https://github.com/kamailio/kamailio/commit/bd7261a5f656a8e723bb6999633c558…
Patch:
https://github.com/kamailio/kamailio/commit/bd7261a5f656a8e723bb6999633c558…
---
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.c
b/src/modules/pua_dialoginfo/pua_dialoginfo.c
index a705ed3e69..83c4f2c3f8 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.c
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.c
@@ -353,6 +353,7 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_para
if(use_pubruri_avps && (refresh_pubruri_avps_flag > -1
|| (request->flags & (1<<refresh_pubruri_avps_flag))))
{
+ lock_get(&dlginfo->lock);
refresh_pubruri_avps(dlginfo, &uri);
}
@@ -496,6 +497,12 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_para
send_publish_flag==-1?1:0,&(dlginfo->uuid));
}
}
+
+ if(use_pubruri_avps && (refresh_pubruri_avps_flag > -1
+ || (request->flags & (1<<refresh_pubruri_avps_flag))))
+ {
+ lock_release(&dlginfo->lock);
+ }
}
/*
@@ -577,6 +584,12 @@ struct dlginfo_cell* get_dialog_data(struct dlg_cell *dlg, int type,
int disable
}
memset( dlginfo, 0, len);
+ if(use_pubruri_avps && lock_init(&dlginfo->lock) == 0) {
+ LM_ERR("cannot init the lock\n");
+ free_dlginfo_cell(dlginfo);
+ return NULL;
+ }
+
/* copy from dlg structure to dlginfo structure */
dlginfo->lifetime = override_lifetime ? override_lifetime : dlg->lifetime;
dlginfo->disable_caller_publish = disable_caller_publish;
@@ -756,20 +769,24 @@ __dialog_created(struct dlg_cell *dlg, int type, struct
dlg_cb_params *_params)
if ((!disable_caller_publish) && (disable_caller_publish_flag == -1 ||
!(request
&& (request->flags & (1<<disable_caller_publish_flag))))) {
+ if(use_pubruri_avps) lock_get(&dlginfo->lock);
dialog_publish_multi("Trying", dlginfo->pubruris_caller,
&identity_local,
&identity_remote,
&(dlg->callid), 1, dlginfo->lifetime,
0, 0, 0, 0, (send_publish_flag==-1)?1:0,&(dlginfo->uuid));
+ if(use_pubruri_avps) lock_release(&dlginfo->lock);
}
if (callee_trying && ((!disable_callee_publish) &&
(disable_callee_publish_flag == -1 || !(request
&& (request->flags & (1<<disable_callee_publish_flag)))))) {
+ if(use_pubruri_avps) lock_get(&dlginfo->lock);
dialog_publish_multi("Trying", dlginfo->pubruris_callee,
&identity_remote,
&identity_local,
&(dlg->callid), 0, dlginfo->lifetime,
0, 0, 0, 0, (send_publish_flag==-1)?1:0,&(dlginfo->uuid));
+ if(use_pubruri_avps) lock_release(&dlginfo->lock);
}
}
@@ -939,9 +956,7 @@ void free_dlginfo_cell(void *param) {
free_str_list_all(cell->pubruris_caller);
free_str_list_all(cell->pubruris_callee);
- /*if (cell->to_tag) {
- shm_free(cell->to_tag);
- }*/
+ if(use_pubruri_avps) lock_destroy(cell->lock);
shm_free(param);
}
diff --git a/src/modules/pua_dialoginfo/pua_dialoginfo.h
b/src/modules/pua_dialoginfo/pua_dialoginfo.h
index d86799adee..04875536f3 100644
--- a/src/modules/pua_dialoginfo/pua_dialoginfo.h
+++ b/src/modules/pua_dialoginfo/pua_dialoginfo.h
@@ -23,6 +23,7 @@
#ifndef _PUA_DLGINFO_H
#define _PUA_DLGINFO_H
+#include "../../core/locking.h"
#include "../pua/pua_bind.h"
extern send_publish_t pua_send_publish;
@@ -35,6 +36,7 @@ void dialog_publish_multi(char *state, struct str_list* ruris, str
*entity, str
* dlg_cell during the callback (as this could create a race condition
* if the dlg_cell gets meanwhile deleted) */
struct dlginfo_cell {
+ gen_lock_t lock;
str from_uri;
str to_uri;
str callid;