Module: kamailio Branch: master Commit: 4d06b1e4bbd371d247301ece057a3c26ae876a9f URL: https://github.com/kamailio/kamailio/commit/4d06b1e4bbd371d247301ece057a3c26...
Author: Olle E. Johansson oej@edvina.net Committer: Olle E. Johansson oej@edvina.net Date: 2021-12-07T10:12:32+01:00
htable: Modify previous commit to create new API for RPC and keep old API for backwards compatibility
Thanks to @miconda for a hint!
---
Modified: src/modules/htable/ht_api.c Modified: src/modules/htable/ht_api.h Modified: src/modules/htable/ht_dmq.c Modified: src/modules/htable/htable.c
---
Diff: https://github.com/kamailio/kamailio/commit/4d06b1e4bbd371d247301ece057a3c26... Patch: https://github.com/kamailio/kamailio/commit/4d06b1e4bbd371d247301ece057a3c26...
---
diff --git a/src/modules/htable/ht_api.c b/src/modules/htable/ht_api.c index 45623e0165..daf088d1f8 100644 --- a/src/modules/htable/ht_api.c +++ b/src/modules/htable/ht_api.c @@ -655,14 +655,33 @@ static void ht_cell_unlink(ht_t *ht, int idx, ht_cell_t *it) ht->entries[idx].esize--; }
-/* Delete htable entry + +/* Delete entry in htable. +Return: + - 1 on error in argument + 0 otherwise +*/ +int ht_del_cell(ht_t *ht, str *name) +{ + int ret; + + ret = ht_del_cell_confirm(ht, name); + if (ret == -1) + return -1; + return 0; +} + +/* Delete htable entry with confirmation + +oldapi = 1 means to always return 0 +oldapi = 0 means to return 1 on successful deletion
Return: -1 on error in argument 0 on entry not found 1 on entry found and deleted */ -int ht_del_cell(ht_t *ht, str *name) +int ht_del_cell_confirm(ht_t *ht, str *name) { unsigned int idx; unsigned int hid; diff --git a/src/modules/htable/ht_api.h b/src/modules/htable/ht_api.h index b9c1551180..4cee835325 100644 --- a/src/modules/htable/ht_api.h +++ b/src/modules/htable/ht_api.h @@ -91,6 +91,7 @@ int ht_init_tables(void); int ht_destroy(void); int ht_set_cell(ht_t *ht, str *name, int type, int_str *val, int mode); int ht_del_cell(ht_t *ht, str *name); +int ht_del_cell_confirm(ht_t *ht, str *name); ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old); int ht_cell_exists(ht_t *ht, str *name);
diff --git a/src/modules/htable/ht_dmq.c b/src/modules/htable/ht_dmq.c index 42e1847d30..6368fb0137 100644 --- a/src/modules/htable/ht_dmq.c +++ b/src/modules/htable/ht_dmq.c @@ -410,6 +410,10 @@ int ht_dmq_replicate_action(ht_dmq_action_t action, str* htname, str* cname, return -1; }
+/* Replay DMQ action + +Return 0 for non-error. Allt other returns are parsed as error. +*/ int ht_dmq_replay_action(ht_dmq_action_t action, str* htname, str* cname, int type, int_str* val, int mode) {
diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c index d491e2e767..78f151daf3 100644 --- a/src/modules/htable/htable.c +++ b/src/modules/htable/htable.c @@ -1454,7 +1454,7 @@ static void htable_rpc_delete(rpc_t* rpc, void* c) { LM_ERR("dmq replication failed\n"); }
- res = ht_del_cell(ht, &keyname); + res = ht_del_cell_confirm(ht, &keyname);
if (res == -1) { rpc->fault(c, 500, "Internal error");