Переглянути джерело

async: allow module to start without internal async timer procs

- async_route() and async_sleep() will return false
- useful when only async_task_route() is used
Daniel-Constantin Mierla 11 роки тому
батько
коміт
879aec4c22
1 змінених файлів з 18 додано та 0 видалено
  1. 18 0
      modules/async/async_mod.c

+ 18 - 0
modules/async/async_mod.c

@@ -100,6 +100,9 @@ static int mod_init(void)
 		return -1;
 	}
 
+	if(async_workers<=0)
+		return 0;
+
 	if(async_init_timer_list()<0) {
 		LM_ERR("cannot initialize internal structure\n");
 		return -1;
@@ -118,6 +121,9 @@ static int child_init(int rank)
 	if (rank!=PROC_MAIN)
 		return 0;
 
+	if(async_workers<=0)
+		return 0;
+
 	if(fork_dummy_timer(PROC_TIMER, "ASYNC MOD TIMER", 1 /*socks flag*/,
 				async_timer_exec, NULL, 1 /*sec*/)<0) {
 		LM_ERR("failed to register timer routine as process\n");
@@ -145,6 +151,12 @@ static int w_async_sleep(struct sip_msg* msg, char* sec, char* str2)
 	if(msg==NULL)
 		return -1;
 
+	if(async_workers<=0)
+	{
+		LM_ERR("no async mod timer wokers\n");
+		return -1;
+	}
+
 	ap = (async_param_t*)sec;
 	if(fixup_get_ivalue(msg, ap->pinterval, &s)!=0)
 	{
@@ -203,6 +215,12 @@ static int w_async_route(struct sip_msg* msg, char* rt, char* sec)
 	if(msg==NULL)
 		return -1;
 
+	if(async_workers<=0)
+	{
+		LM_ERR("no async mod timer wokers\n");
+		return -1;
+	}
+
 	if(fixup_get_svalue(msg, (gparam_t*)rt, &rn)!=0)
 	{
 		LM_ERR("no async route block name\n");