Browse code

kazoo - fix timer interval

amqp timer and publish proc take all cpu
new param amqp_timmer_process_interval in MS
and removed the timeout on select from tcp workers

Luis Azedo authored on 24/02/2015 22:22:32
Showing 2 changed files
... ...
@@ -70,6 +70,8 @@ struct timeval kz_sock_tv = (struct timeval){0,100000};
70 70
 struct timeval kz_amqp_tv = (struct timeval){0,100000};
71 71
 struct timeval kz_qtimeout_tv = (struct timeval){2,0};
72 72
 struct timeval kz_ack_tv = (struct timeval){0,100000};
73
+struct timeval kz_timer_tv = (struct timeval){0,200000};
74
+int kz_timer_ms = 200;
73 75
 
74 76
 
75 77
 str dbk_consumer_event_key = str_init("Event-Category");
... ...
@@ -148,6 +150,7 @@ static param_export_t params[] = {
148 148
   //  {"mwi_expires", INT_PARAM, &dbk_mwi_expires},
149 149
     {"amqp_connection", STR_PARAM|USE_FUNC_PARAM,(void*)kz_amqp_add_connection},
150 150
     {"amqp_max_channels", INT_PARAM, &dbk_channels},
151
+    {"amqp_timmer_process_interval", INT_PARAM, &kz_timer_ms},
151 152
     {"amqp_consumer_ack_timeout_micro", INT_PARAM, &kz_ack_tv.tv_usec},
152 153
     {"amqp_consumer_ack_timeout_sec", INT_PARAM, &kz_ack_tv.tv_sec},
153 154
     {"amqp_interprocess_timeout_micro", INT_PARAM, &kz_sock_tv.tv_usec},
... ...
@@ -235,6 +238,11 @@ static int mod_init(void) {
235 235
     if(!kz_amqp_init()) {
236 236
    		return -1;
237 237
     }
238
+
239
+    if(kz_timer_ms > 0) {
240
+    	kz_timer_tv.tv_usec = (kz_timer_ms  1000) * 1000;
241
+    	kz_timer_tv.tv_sec = kz_timer_ms / 1000;
242
+    }
238 243
     
239 244
     if(dbk_pua_mode == 1) {
240 245
 		kz_db_url.len = kz_db_url.s ? strlen(kz_db_url.s) : 0;
... ...
@@ -35,6 +35,7 @@ extern struct timeval kz_sock_tv;
35 35
 extern struct timeval kz_amqp_tv;
36 36
 extern struct timeval kz_qtimeout_tv;
37 37
 extern struct timeval kz_ack_tv;
38
+extern struct timeval kz_timer_tv;
38 39
 
39 40
 extern int dbk_internal_loop_count;
40 41
 extern int dbk_consumer_loop_count;
... ...
@@ -1909,6 +1910,7 @@ void kz_amqp_timeout_proc(int child_no)
1909 1909
 	int i;
1910 1910
     while(1) {
1911 1911
 		struct timeval now;
1912
+		usleep(kz_timer_tv.tv_usec);
1912 1913
 		for(i=0; i < dbk_channels; i++) {
1913 1914
 			gettimeofday(&now, NULL);
1914 1915
 			if(channels[i].state == KZ_AMQP_CALLING
... ...
@@ -1972,7 +1974,7 @@ void kz_amqp_publisher_proc(int child_no)
1972 1972
     	while(OK) {
1973 1973
 			FD_ZERO(&fdset);
1974 1974
 			FD_SET(data_pipe, &fdset);
1975
-			selret = select(FD_SETSIZE, &fdset, NULL, NULL, &kz_sock_tv);
1975
+			selret = select(FD_SETSIZE, &fdset, NULL, NULL, NULL);
1976 1976
 			if (selret < 0) {
1977 1977
 				LM_ERR("select() failed: %s\n", strerror(errno));
1978 1978
 				continue;