[sr-dev] git:master: core: async_workers - new core parameter

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 14 14:32:34 CEST 2014


Module: sip-router
Branch: master
Commit: d5a22ca880d04549b4f65086bcfd2f3f67311bcb
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d5a22ca880d04549b4f65086bcfd2f3f67311bcb

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Apr 14 14:17:36 2014 +0200

core: async_workers - new core parameter

- specify how many processes to create for asyn framework
- default is 0 (asyn framework disabled)
- you must set it to >0 to enable it

---

 cfg.lex     |    2 ++
 cfg.y       |    4 ++++
 main.c      |    1 +
 sr_module.c |   12 ++++++++++++
 4 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/cfg.lex b/cfg.lex
index 3d4b889..7435bb2 100644
--- a/cfg.lex
+++ b/cfg.lex
@@ -392,6 +392,7 @@ MAXBUFFER maxbuffer
 SQL_BUFFER_SIZE sql_buffer_size
 CHILDREN children
 SOCKET_WORKERS socket_workers
+ASYNC_WORKERS async_workers
 CHECK_VIA	check_via
 PHONE2TEL	phone2tel
 MEMLOG		"memlog"|"mem_log"
@@ -775,6 +776,7 @@ IMPORTFILE      "import_file"
 <INITIAL>{SQL_BUFFER_SIZE}	{ count(); yylval.strval=yytext; return SQL_BUFFER_SIZE; }
 <INITIAL>{CHILDREN}	{ count(); yylval.strval=yytext; return CHILDREN; }
 <INITIAL>{SOCKET_WORKERS}	{ count(); yylval.strval=yytext; return SOCKET_WORKERS; }
+<INITIAL>{ASYNC_WORKERS}	{ count(); yylval.strval=yytext; return ASYNC_WORKERS; }
 <INITIAL>{CHECK_VIA}	{ count(); yylval.strval=yytext; return CHECK_VIA; }
 <INITIAL>{PHONE2TEL}	{ count(); yylval.strval=yytext; return PHONE2TEL; }
 <INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
diff --git a/cfg.y b/cfg.y
index fd0fd2c..2e75bc7 100644
--- a/cfg.y
+++ b/cfg.y
@@ -141,6 +141,7 @@
 #include "rvalue.h"
 #include "sr_compat.h"
 #include "msg_translator.h"
+#include "async_task.h"
 
 #include "ppcfg.h"
 #include "pvapi.h"
@@ -439,6 +440,7 @@ extern char *finame;
 %token STAT
 %token CHILDREN
 %token SOCKET_WORKERS
+%token ASYNC_WORKERS
 %token CHECK_VIA
 %token PHONE2TEL
 %token MEMLOG
@@ -938,6 +940,8 @@ assign_stm:
 	| CHILDREN EQUAL error { yyerror("number expected"); }
 	| SOCKET_WORKERS EQUAL NUMBER { socket_workers=$3; }
 	| SOCKET_WORKERS EQUAL error { yyerror("number expected"); }
+	| ASYNC_WORKERS EQUAL NUMBER { async_task_set_workers($3); }
+	| ASYNC_WORKERS EQUAL error { yyerror("number expected"); }
 	| CHECK_VIA EQUAL NUMBER { check_via=$3; }
 	| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
 	| PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
diff --git a/main.c b/main.c
index b86b67d..89115a4 100644
--- a/main.c
+++ b/main.c
@@ -190,6 +190,7 @@
 #include "pv_core.h" /* register core pvars */
 #include "ppcfg.h"
 #include "sock_ut.h"
+#include "async_task.h"
 
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
diff --git a/sr_module.c b/sr_module.c
index e169291..3fb98a6 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -65,6 +65,7 @@
 #include "rpc_lookup.h"
 #include "sr_compat.h"
 #include "ppcfg.h"
+#include "async_task.h"
 
 #include <sys/stat.h>
 #include <regex.h>
@@ -842,6 +843,9 @@ int init_modules(void)
 {
 	struct sr_module* t;
 
+	if(async_task_init()<0)
+		return -1;
+
 	for(t = modules; t; t = t->next) {
 		if (t->exports.init_f) {
 			if (t->exports.init_f() != 0) {
@@ -891,6 +895,8 @@ int init_child(int rank)
 	}
 	DBG("init_child: initializing %s with rank %d\n", type, rank);
 
+	if(async_task_child_init(rank)<0)
+		return -1;
 
 	for(t = modules; t; t = t->next) {
 		if (t->exports.init_child_f) {
@@ -945,6 +951,9 @@ static int init_mod_child( struct sr_module* m, int rank )
  */
 int init_child(int rank)
 {
+	if(async_task_child_init(rank)<0)
+		return -1;
+
 	return init_mod_child(modules, rank);
 }
 
@@ -991,6 +1000,9 @@ int init_modules(void)
 	struct sr_module* t;
 	int i;
 	
+	if(async_task_init()<0)
+		return -1;
+
 	i = init_mod(modules);
 	if(i!=0)
 		return i;




More information about the sr-dev mailing list