Module: kamailio
Branch: master
Commit: f24ea7d3a5482b4e74e0bd682e2f10cca06e615e
URL:
https://github.com/kamailio/kamailio/commit/f24ea7d3a5482b4e74e0bd682e2f10c…
Author: grumvalski <federico.cabiddu(a)gmail.com>
Committer: grumvalski <federico.cabiddu(a)gmail.com>
Date: 2018-09-28T14:36:14+02:00
core: new parameter async_nonblock
---
Modified: src/core/async_task.c
Modified: src/core/async_task.h
Modified: src/core/cfg.lex
Modified: src/core/cfg.y
---
Diff:
https://github.com/kamailio/kamailio/commit/f24ea7d3a5482b4e74e0bd682e2f10c…
Patch:
https://github.com/kamailio/kamailio/commit/f24ea7d3a5482b4e74e0bd682e2f10c…
---
diff --git a/src/core/async_task.c b/src/core/async_task.c
index ab2376a446..a6b9d4ef8d 100644
--- a/src/core/async_task.c
+++ b/src/core/async_task.c
@@ -47,6 +47,7 @@
static int _async_task_workers = 0;
static int _async_task_sockets[2];
static int _async_task_usleep = 0;
+static int _async_nonblock = 0;
int async_task_run(int idx);
@@ -78,6 +79,10 @@ int async_task_init_sockets(void)
LM_ERR("opening tasks dgram socket pair\n");
return -1;
}
+
+ if (_async_nonblock)
+ fcntl(_async_task_sockets[1], F_SETFL, fcntl(_async_task_sockets[1], F_GETFL, 0) |
O_NONBLOCK);
+
LM_DBG("inter-process event notification sockets initialized\n");
return 0;
}
@@ -194,6 +199,17 @@ int async_task_set_workers(int n)
return 0;
}
+/**
+ *
+ */
+int async_task_set_nonblock(int n)
+{
+ if(n>0)
+ _async_nonblock = 1;
+
+ return 0;
+}
+
/**
*
*/
diff --git a/src/core/async_task.h b/src/core/async_task.h
index 55c558c30d..5faa884570 100644
--- a/src/core/async_task.h
+++ b/src/core/async_task.h
@@ -35,6 +35,7 @@ int async_task_init(void);
int async_task_child_init(int rank);
int async_task_initialized(void);
int async_task_set_workers(int n);
+int async_task_set_nonblock(int n);
int async_task_push(async_task_t *task);
int async_task_set_usleep(int n);
int async_task_workers_get(void);
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index ddef8a03ea..4a49cc1d11 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -348,6 +348,7 @@ CHILDREN children
SOCKET_WORKERS socket_workers
ASYNC_WORKERS async_workers
ASYNC_USLEEP async_usleep
+ASYNC_NONBLOCK async_nonblock
CHECK_VIA check_via
PHONE2TEL phone2tel
MEMLOG "memlog"|"mem_log"
@@ -780,6 +781,7 @@ IMPORTFILE "import_file"
<INITIAL>{SOCKET_WORKERS} { count(); yylval.strval=yytext; return SOCKET_WORKERS;
}
<INITIAL>{ASYNC_WORKERS} { count(); yylval.strval=yytext; return ASYNC_WORKERS; }
<INITIAL>{ASYNC_USLEEP} { count(); yylval.strval=yytext; return ASYNC_USLEEP; }
+<INITIAL>{ASYNC_NONBLOCK} { count(); yylval.strval=yytext; return ASYNC_NONBLOCK;
}
<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/src/core/cfg.y b/src/core/cfg.y
index e77a42cd6e..66833cde09 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -376,6 +376,7 @@ extern char *default_routename;
%token SOCKET_WORKERS
%token ASYNC_WORKERS
%token ASYNC_USLEEP
+%token ASYNC_NONBLOCK
%token CHECK_VIA
%token PHONE2TEL
%token MEMLOG
@@ -909,6 +910,8 @@ assign_stm:
| ASYNC_WORKERS EQUAL error { yyerror("number expected"); }
| ASYNC_USLEEP EQUAL NUMBER { async_task_set_usleep($3); }
| ASYNC_USLEEP EQUAL error { yyerror("number expected"); }
+ | ASYNC_NONBLOCK EQUAL NUMBER { async_task_set_nonblock($3); }
+ | ASYNC_NONBLOCK 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; }