From 53664ba26af389855444c1c2c6a78d53b276c0a0 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 3 Dec 2020 13:50:58 +0100 Subject: [PATCH] htable: replicate the operation rm with sw - GH #2573 --- src/modules/htable/ht_dmq.c | 15 +++++++++++---- src/modules/htable/ht_dmq.h | 3 ++- src/modules/htable/htable.c | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/modules/htable/ht_dmq.c b/src/modules/htable/ht_dmq.c index ccb67e30d8c..42e1847d305 100644 --- a/src/modules/htable/ht_dmq.c +++ b/src/modules/htable/ht_dmq.c @@ -350,7 +350,9 @@ int ht_dmq_handle_msg(struct sip_msg* msg, peer_reponse_t* resp, dmq_node_t* dmq return 0; } -int ht_dmq_replicate_action(ht_dmq_action_t action, str* htname, str* cname, int type, int_str* val, int mode) { +int ht_dmq_replicate_action(ht_dmq_action_t action, str* htname, str* cname, + int type, int_str* val, int mode) +{ srjson_doc_t jdoc; @@ -370,7 +372,8 @@ int ht_dmq_replicate_action(ht_dmq_action_t action, str* htname, str* cname, int srjson_AddStrToObject(&jdoc, jdoc.root, "cname", cname->s, cname->len); } - if (action==HT_DMQ_SET_CELL || action==HT_DMQ_SET_CELL_EXPIRE || action==HT_DMQ_RM_CELL_RE) { + if (action==HT_DMQ_SET_CELL || action==HT_DMQ_SET_CELL_EXPIRE + || action==HT_DMQ_RM_CELL_RE || action==HT_DMQ_RM_CELL_SW) { srjson_AddNumberToObject(&jdoc, jdoc.root, "type", type); if (type&AVP_VAL_STR) { srjson_AddStrToObject(&jdoc, jdoc.root, "strval", val->s.s, val->s.len); @@ -407,7 +410,8 @@ int ht_dmq_replicate_action(ht_dmq_action_t action, str* htname, str* cname, int return -1; } -int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, int type, int_str* val, int mode) { +int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, + int type, int_str* val, int mode) { ht_t* ht; ht = ht_get_table(htname); @@ -416,7 +420,8 @@ int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, int ty return -1; } - LM_DBG("replaying action %d on %.*s=>%.*s...\n", action, htname->len, htname->s, cname->len, cname->s); + LM_DBG("replaying action %d on %.*s=>%.*s...\n", action, + htname->len, htname->s, cname->len, cname->s); if (action==HT_DMQ_SET_CELL) { return ht_set_cell(ht, cname, type, val, mode); @@ -426,6 +431,8 @@ int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, int ty return ht_del_cell(ht, cname); } else if (action==HT_DMQ_RM_CELL_RE) { return ht_rm_cell_re(&val->s, ht, mode); + } else if (action==HT_DMQ_RM_CELL_SW) { + return ht_rm_cell_op(&val->s, ht, mode, HT_RM_OP_SW); } else { LM_ERR("unrecognized action\n"); return -1; diff --git a/src/modules/htable/ht_dmq.h b/src/modules/htable/ht_dmq.h index 55f2af783da..22c4876191c 100644 --- a/src/modules/htable/ht_dmq.h +++ b/src/modules/htable/ht_dmq.h @@ -33,11 +33,12 @@ extern dmq_resp_cback_t ht_dmq_resp_callback; typedef enum { HT_DMQ_NONE, + HT_DMQ_SYNC, HT_DMQ_SET_CELL, HT_DMQ_SET_CELL_EXPIRE, HT_DMQ_DEL_CELL, HT_DMQ_RM_CELL_RE, - HT_DMQ_SYNC + HT_DMQ_RM_CELL_SW } ht_dmq_action_t; int ht_dmq_initialize(); diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c index 55717ecd948..d449839c2fd 100644 --- a/src/modules/htable/htable.c +++ b/src/modules/htable/htable.c @@ -493,6 +493,10 @@ static int ht_rm_items(sip_msg_t* msg, str* hname, str* op, str *val, } return 1; } else if(strncmp(op->s, "sw", 2)==0) { + if (ht_dmq_replicate_action(HT_DMQ_RM_CELL_SW, &ht->name, NULL, + AVP_VAL_STR, &isval, mkey)!=0) { + LM_ERR("dmq relication failed (op %d)\n", mkey); + } if(ht_rm_cell_op(val, ht, mkey, HT_RM_OP_SW)<0) { return -1; }