Browse Source

async: coherent indentation and white spacing

Daniel-Constantin Mierla 6 years ago
parent
commit
95ac7eaa5e
2 changed files with 27 additions and 23 deletions
  1. 14 10
      src/modules/async/async_mod.c
  2. 13 13
      src/modules/async/async_sleep.c

+ 14 - 10
src/modules/async/async_mod.c

@@ -115,14 +115,16 @@ static int mod_init(void)
 		return -1;
 	}
 
-        if(async_ms_timer == 0) {
-                LM_INFO("ms_timer is set to 0. Disabling async_ms_sleep and async_ms_route functions\n");
-        } else {
+	if(async_ms_timer == 0) {
+		LM_INFO("ms_timer is set to 0. Disabling async_ms_sleep"
+				" and async_ms_route functions\n");
+	} else {
 		if(async_init_ms_timer_list() < 0) {
 			LM_ERR("cannot initialize internal structure\n");
 			return -1;
 		}
-                LM_INFO("Enabled async_ms_sleep and async_ms_route functions with resolution of %dms\n", async_ms_timer);
+		LM_INFO("Enabled async_ms_sleep and async_ms_route functions"
+				" with resolution of %dms\n", async_ms_timer);
 	}
 
 	register_basic_timers(async_workers + (async_ms_timer > 0));
@@ -145,17 +147,19 @@ static int child_init(int rank)
 
 	for(i = 0; i < async_workers; i++) {
 		if(fork_basic_timer(PROC_TIMER, "ASYNC MOD TIMER", 1 /*socks flag*/,
-				   async_timer_exec, NULL, 1 /*sec*/)
+					async_timer_exec, NULL, 1 /*sec*/)
 				< 0) {
 			LM_ERR("failed to register timer routine as process (%d)\n", i);
 			return -1; /* error */
 		}
 	}
-	
-	if((async_ms_timer > 0) && fork_basic_utimer(PROC_TIMER, "ASYNC MOD MILLI TIMER SINGLETON", 1 /*socks flag*/,
-			   async_mstimer_exec, NULL, 1000 * async_ms_timer /*milliseconds*/)
+
+	if((async_ms_timer > 0) && fork_basic_utimer(PROC_TIMER,
+				"ASYNC MOD MILLI TIMER SINGLETON", 1 /*socks flag*/,
+				async_mstimer_exec, NULL, 1000 * async_ms_timer /*milliseconds*/)
 			< 0) {
-		LM_ERR("failed to register millisecond timer singleton as process (%d)\n", i);
+		LM_ERR("failed to register millisecond timer singleton as process (%d)\n",
+				i);
 		return -1; /* error */
 	}
 
@@ -479,7 +483,7 @@ static int fixup_async_task_route(void **param, int param_no)
 {
 	if(!async_task_initialized()) {
 		LM_ERR("async task framework was not initialized"
-			   " - set async_workers parameter in core\n");
+				" - set async_workers parameter in core\n");
 		return -1;
 	}
 

+ 13 - 13
src/modules/async/async_sleep.c

@@ -137,7 +137,7 @@ int async_init_ms_timer_list(void)
 }
 
 int async_destroy_ms_timer_list(void)
-{	
+{
 	if (_async_ms_list) {
 		lock_destroy(&_async_ms_list->lock);
 		shm_free(_async_ms_list);
@@ -160,10 +160,10 @@ int async_destroy_timer_list(void)
 	return 0;
 }
 
-int async_insert_item(async_ms_item_t *ai) 
+int async_insert_item(async_ms_item_t *ai)
 {
 	struct timeval *due = &ai->due;
-	
+
 	if (unlikely(_async_ms_list == NULL))
 		return -1;
 	lock_get(&_async_ms_list->lock);
@@ -194,7 +194,7 @@ int async_insert_item(async_ms_item_t *ai)
 	}
 	_async_ms_list->len++;
 	lock_release(&_async_ms_list->lock);
-	return 0;	
+	return 0;
 }
 
 
@@ -307,16 +307,16 @@ void async_mstimer_exec(unsigned int ticks, void *param)
 	if (_async_ms_list == NULL)
 		return;
 	lock_get(&_async_ms_list->lock);
-	
+
 	async_ms_item_t *aip, *next;
 	int i = 0;
 	for (aip = _async_ms_list->lstart; aip; aip = next, i++) {
 		next = aip->next;
 		if (timercmp(&now, &aip->due, >=)) {
-			if ((_async_ms_list->lstart = next) == NULL) 
+			if ((_async_ms_list->lstart = next) == NULL)
 				_async_ms_list->lend = NULL;
 			if (async_task_push(aip->at)<0) {
-		                shm_free(aip->at);
+				shm_free(aip->at);
 			}
 			_async_ms_list->len--;
 			continue;
@@ -325,7 +325,7 @@ void async_mstimer_exec(unsigned int ticks, void *param)
 	}
 
 	lock_release(&_async_ms_list->lock);
-	
+
 	return;
 
 }
@@ -403,7 +403,7 @@ int async_ms_sleep(sip_msg_t *msg, int milliseconds, cfg_action_t *act, str *cbn
 			return -1;
 		}
 	}
-	
+
 	if(tmb.t_suspend(msg, &tindex, &tlabel) < 0) {
 		LM_ERR("failed to suspend the processing\n");
 		return -1;
@@ -432,13 +432,13 @@ int async_ms_sleep(sip_msg_t *msg, int milliseconds, cfg_action_t *act, str *cbn
 		atp->cbname[cbname->len] = '\0';
 		atp->cbname_len = cbname->len;
 	}
-	
+
 	struct timeval now, upause;
 	gettimeofday(&now, NULL);
-	upause.tv_sec = milliseconds / 1000; 
+	upause.tv_sec = milliseconds / 1000;
 	upause.tv_usec = (milliseconds * 1000) % 1000000;
-	
-	timeradd(&now, &upause, &ai->due);	
+
+	timeradd(&now, &upause, &ai->due);
 	async_insert_item(ai);
 
 	return 0;