Module: kamailio
Branch: master
Commit: 629c1674fcbbfd12310da924e8b6cd5116cd71a3
URL:
https://github.com/kamailio/kamailio/commit/629c1674fcbbfd12310da924e8b6cd5…
Author: PaweÅ PierÅcionek <ppierscionek(a)gmail.com>
Committer: Henning Westerholt <henningw(a)users.noreply.github.com>
Date: 2019-07-28T16:28:35+02:00
sync: added support for millisecond resolution sleep
- new ms_timer parameter to enable millisecond precision timer
- new async_ms_route and async_ms_sleep functions with milliseconds as a param
- implementation:
Each async_ms_sleep adds an entry to a linked list sorted by expiry time.
List is checked every ms_timer ms for expired entries.
All expired entries are pushed for execution on a pool of async workers.
---
Modified: src/modules/async/async_sleep.c
---
Diff:
https://github.com/kamailio/kamailio/commit/629c1674fcbbfd12310da924e8b6cd5…
Patch:
https://github.com/kamailio/kamailio/commit/629c1674fcbbfd12310da924e8b6cd5…
---
diff --git a/src/modules/async/async_sleep.c b/src/modules/async/async_sleep.c
index ff1da14639..0e78879483 100644
--- a/src/modules/async/async_sleep.c
+++ b/src/modules/async/async_sleep.c
@@ -130,7 +130,7 @@ int async_init_ms_timer_list(void)
if(lock_init(&_async_ms_list->lock) == 0) {
LM_ERR("cannot init lock \n");
shm_free(_async_ms_list);
- _async_ms_list = 0;
+ _async_ms_list = NULL;
return -1;
}
return 0;
@@ -140,6 +140,8 @@ int async_destroy_ms_timer_list(void)
{
if (_async_ms_list) {
lock_destroy(&_async_ms_list->lock);
+ shm_free(_async_ms_list);
+ _async_ms_list = NULL;
}
return 0;
}
@@ -384,19 +386,6 @@ int async_ms_sleep(sip_msg_t *msg, int milliseconds, cfg_action_t
*act, str *cbn
LM_ERR("callback name is too long: %.*s\n", cbname->len, cbname->s);
return -1;
}
- dsize = sizeof(async_task_t) + sizeof(async_task_param_t) + sizeof(async_ms_item_t);
-
- at = (async_task_t *)shm_malloc(dsize);
- if(at == NULL) {
- LM_ERR("no more shm memory\n");
- return -1;
- }
- memset(at, 0, dsize);
- at->param = (char *)at + sizeof(async_task_t);
- atp = (async_task_param_t *)at->param;
- ai = (async_ms_item_t *) ((char *)at + sizeof(async_task_t) +
sizeof(async_task_param_t));
- ai->at = at;
-
if(cbname && cbname->len>=ASYNC_CBNAME_SIZE-1) {
LM_ERR("callback name is too long: %.*s\n", cbname->len, cbname->s);
return -1;
@@ -417,9 +406,22 @@ int async_ms_sleep(sip_msg_t *msg, int milliseconds, cfg_action_t
*act, str *cbn
if(tmb.t_suspend(msg, &tindex, &tlabel) < 0) {
LM_ERR("failed to suspend the processing\n");
- shm_free(ai);
return -1;
}
+
+ dsize = sizeof(async_task_t) + sizeof(async_task_param_t) + sizeof(async_ms_item_t);
+
+ at = (async_task_t *)shm_malloc(dsize);
+ if(at == NULL) {
+ LM_ERR("no more shm memory\n");
+ return -1;
+ }
+ memset(at, 0, dsize);
+ at->param = (char *)at + sizeof(async_task_t);
+ atp = (async_task_param_t *)at->param;
+ ai = (async_ms_item_t *) ((char *)at + sizeof(async_task_t) +
sizeof(async_task_param_t));
+ ai->at = at;
+
at->exec = async_exec_task;
at->param = atp;
atp->ract = act;