[sr-dev] git:master:5e274713: siprepo: unlink item from hash table based on rmode
Daniel-Constantin Mierla
miconda at gmail.com
Mon Apr 25 15:09:00 CEST 2022
Module: kamailio
Branch: master
Commit: 5e27471312c110ce19cfa0bfa5a29abcd03daec6
URL: https://github.com/kamailio/kamailio/commit/5e27471312c110ce19cfa0bfa5a29abcd03daec6
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-04-25T15:08:15+02:00
siprepo: unlink item from hash table based on rmode
---
Modified: src/modules/siprepo/siprepo_data.c
Modified: src/modules/siprepo/siprepo_data.h
---
Diff: https://github.com/kamailio/kamailio/commit/5e27471312c110ce19cfa0bfa5a29abcd03daec6.diff
Patch: https://github.com/kamailio/kamailio/commit/5e27471312c110ce19cfa0bfa5a29abcd03daec6.patch
---
diff --git a/src/modules/siprepo/siprepo_data.c b/src/modules/siprepo/siprepo_data.c
index 0c9873e3c2..603d3744c1 100644
--- a/src/modules/siprepo/siprepo_data.c
+++ b/src/modules/siprepo/siprepo_data.c
@@ -108,6 +108,25 @@ siprepo_msg_t *siprepo_msg_find(sip_msg_t *msg, str *callid, str *msgid, int lmo
return 0;
}
+/**
+ *
+ */
+void siprepo_msg_unlink(siprepo_msg_t *it, unsigned int slotid)
+{
+ if(it->prev==NULL) {
+ _siprepo_table[slotid].plist = it->next;
+ if(_siprepo_table[slotid].plist) {
+ _siprepo_table[slotid].plist->prev = NULL;
+ }
+ } else {
+ it->prev->next = it->next;
+ }
+ if(it->next!=NULL) {
+ it->next->prev = it->prev;
+ }
+ return;
+}
+
/**
*
*/
@@ -334,9 +353,15 @@ int siprepo_msg_pull(sip_msg_t *msg, str *callid, str *msgid, str *rname,
lmsg.set_global_address = default_global_address;
lmsg.set_global_port = default_global_port;
+ if(rmode & SIPREPO_RMODE_RM) {
+ siprepo_msg_unlink(it, slotid);
+ shm_free(it);
+ }
+
+ lock_release(&_siprepo_table[slotid].lock);
+
if(parse_msg(lmsg.buf, lmsg.len, &lmsg) != 0) {
LM_ERR("failed to parse msg id [%.*s]\n", msgid->len, msgid->s);
- lock_release(&_siprepo_table[slotid].lock);
return 1;
}
if(unlikely(parse_headers(&lmsg, HDR_FROM_F|HDR_TO_F|HDR_CALLID_F|HDR_CSEQ_F, 0)
@@ -394,17 +419,7 @@ void siprepo_timer_exec(unsigned int ticks, int worker, void *param)
lock_get(&_siprepo_table[i].lock);
for(it=_siprepo_table[i].plist; it!=NULL; it=it->next) {
if(it->itime+_siprepo_expire < tnow) {
- if(it->prev==NULL) {
- _siprepo_table[i].plist = it->next;
- if(_siprepo_table[i].plist) {
- _siprepo_table[i].plist->prev = NULL;
- }
- } else {
- it->prev->next = it->next;
- }
- if(it->next!=NULL) {
- it->next->prev = it->prev;
- }
+ siprepo_msg_unlink(it, slotid);
if(elist) {
it->next = elist;
elist = it;
diff --git a/src/modules/siprepo/siprepo_data.h b/src/modules/siprepo/siprepo_data.h
index 2750189ae0..683348c8b0 100644
--- a/src/modules/siprepo/siprepo_data.h
+++ b/src/modules/siprepo/siprepo_data.h
@@ -27,6 +27,8 @@
#include "../../core/parser/msg_parser.h"
+#define SIPREPO_RMODE_RM 1
+
typedef struct siprepo_msg {
unsigned int hid;
int mtype;
More information about the sr-dev
mailing list