Module: kamailio Branch: master Commit: 836f30f0a173de11124165361f5bc068c6c10fbb URL: https://github.com/kamailio/kamailio/commit/836f30f0a173de11124165361f5bc068...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-07-17T10:04:52+02:00
misctest: function to unlock global lock used with threads
---
Modified: src/modules/misctest/misctest_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/836f30f0a173de11124165361f5bc068... Patch: https://github.com/kamailio/kamailio/commit/836f30f0a173de11124165361f5bc068...
---
diff --git a/src/modules/misctest/misctest_mod.c b/src/modules/misctest/misctest_mod.c index 519d68ab81a..e02bb52fd41 100644 --- a/src/modules/misctest/misctest_mod.c +++ b/src/modules/misctest/misctest_mod.c @@ -60,6 +60,7 @@ static int mt_mem_free_f(struct sip_msg *, char *, char *); static int mt_tcp_thread_exec_f(sip_msg_t *, char *, char *); static int mt_lock_test_f(struct sip_msg *, char *, char *); static int mt_lock_threads_f(sip_msg_t *, char *, char *); +static int mt_unlock_threads_f(sip_msg_t *, char *, char *); static int mod_init(void); static void mod_destroy(void);
@@ -83,6 +84,8 @@ static cmd_export_t cmds[]={ {"mt_lock_test", mt_lock_test_f, 1, fixup_var_int_1, 0, ANY_ROUTE}, {"mt_lock_threads", mt_lock_threads_f, 1, fixup_igp_null, fixup_free_igp_null, ANY_ROUTE}, + {"mt_unlock_threads", mt_unlock_threads_f, 1, fixup_igp_null, + fixup_free_igp_null, ANY_ROUTE}, {0, 0, 0, 0, 0} }; /* clang-format on */ @@ -1080,6 +1083,31 @@ static int mt_lock_threads_f(sip_msg_t *msg, char *pn, char *p2) return -1; }
+static int mt_unlock_threads_f(sip_msg_t *msg, char *pn, char *p2) +{ + int i; + int n; + + if(fixup_get_ivalue(msg, (gparam_t *)pn, &n) < 0) { + LM_ERR("invalid parameter\n"); + return -1; + } + + if(_misctest_lock_threads == NULL) { + LM_ERR("the lock is not initialized\n"); + goto error; + } + + for(i = 0; i < n; i++) { + lock_release(_misctest_lock_threads); + } + + return 1; + +error: + return -1; +} + /* RPC exports: */