Module: kamailio
Branch: 5.0
Commit: 8038327f7c0c6e64899072f1c778699f040b2a0a
URL:
https://github.com/kamailio/kamailio/commit/8038327f7c0c6e64899072f1c778699…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-06-26T14:02:34+02:00
htable: do not call expired event route on get/add operations
- have consistent behaviour with set operation
- avoid accessing the same (expired) item twice, second after being
removed if the item is accessed in the event route
- reported by GH #1152
(cherry picked from commit 4514c91883d67ee062582aed7b414633609cf6ac)
---
Modified: src/modules/htable/ht_api.c
Modified: src/modules/htable/ht_var.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8038327f7c0c6e64899072f1c778699…
Patch:
https://github.com/kamailio/kamailio/commit/8038327f7c0c6e64899072f1c778699…
---
diff --git a/src/modules/htable/ht_api.c b/src/modules/htable/ht_api.c
index 4c4ba5315b..a6e9c0eba6 100644
--- a/src/modules/htable/ht_api.c
+++ b/src/modules/htable/ht_api.c
@@ -676,7 +676,6 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
/* found */
if(now>0 && it->expire!=0 && it->expire<now) {
/* entry has expired */
- ht_handle_expired_record(ht, it);
if(ht->flags==PV_VAL_INT) {
/* initval is integer, use it to create a fresh entry */
@@ -684,16 +683,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
it->value.n = ht->initval.n;
/* increment will be done below */
} else {
- /* delete expired entry */
- if(it->prev==NULL)
- ht->entries[idx].first = it->next;
- else
- it->prev->next = it->next;
- if(it->next)
- it->next->prev = it->prev;
- ht->entries[idx].esize--;
if(mode) ht_slot_unlock(ht, idx);
- ht_cell_free(it);
return NULL;
}
}
@@ -804,18 +794,8 @@ ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old)
{
/* found */
if(ht->htexpire>0 && it->expire!=0 &&
it->expire<time(NULL)) {
- /* entry has expired, delete it and return NULL */
- ht_handle_expired_record(ht, it);
-
- if(it->prev==NULL)
- ht->entries[idx].first = it->next;
- else
- it->prev->next = it->next;
- if(it->next)
- it->next->prev = it->prev;
- ht->entries[idx].esize--;
+ /* entry has expired, return NULL */
ht_slot_unlock(ht, idx);
- ht_cell_free(it);
return NULL;
}
if(old!=NULL)
diff --git a/src/modules/htable/ht_var.c b/src/modules/htable/ht_var.c
index 522811da58..c928bf1b49 100644
--- a/src/modules/htable/ht_var.c
+++ b/src/modules/htable/ht_var.c
@@ -91,7 +91,9 @@ int pv_set_ht_cell(struct sip_msg* msg, pv_param_t *param,
if((val==NULL) || (val->flags&PV_VAL_NULL))
{
/* delete it */
- if (hpv->ht->dmqreplicate>0 &&
ht_dmq_replicate_action(HT_DMQ_DEL_CELL, &hpv->htname, &htname, 0, NULL, 0)!=0)
{
+ if (hpv->ht->dmqreplicate>0
+ && ht_dmq_replicate_action(HT_DMQ_DEL_CELL, &hpv->htname,
+ &htname, 0, NULL, 0)!=0) {
LM_ERR("dmq relication failed\n");
}
ht_del_cell(hpv->ht, &htname);
@@ -101,7 +103,9 @@ int pv_set_ht_cell(struct sip_msg* msg, pv_param_t *param,
if(val->flags&PV_TYPE_INT)
{
isval.n = val->ri;
- if (hpv->ht->dmqreplicate>0 &&
ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, 0, &isval,
1)!=0) {
+ if (hpv->ht->dmqreplicate>0
+ && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname,
+ &htname, 0, &isval, 1)!=0) {
LM_ERR("dmq relication failed\n");
}
if(ht_set_cell(hpv->ht, &htname, 0, &isval, 1)!=0)
@@ -111,7 +115,9 @@ int pv_set_ht_cell(struct sip_msg* msg, pv_param_t *param,
}
} else {
isval.s = val->rs;
- if (hpv->ht->dmqreplicate>0 &&
ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, AVP_VAL_STR,
&isval, 1)!=0) {
+ if (hpv->ht->dmqreplicate>0
+ && ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname,
+ &htname, AVP_VAL_STR, &isval, 1)!=0) {
LM_ERR("dmq relication failed\n");
}
if(ht_set_cell(hpv->ht, &htname, AVP_VAL_STR, &isval, 1)!=0)