diff --git a/async_task.c b/async_task.c index 019f49315f4..956bd9ae8b2 100644 --- a/async_task.c +++ b/async_task.c @@ -46,6 +46,7 @@ static int _async_task_workers = 0; static int _async_task_sockets[2]; +static int _async_task_usleep = 0; int async_task_run(int idx); @@ -174,6 +175,19 @@ int async_task_set_workers(int n) return 0; } +/** + * + */ +int async_task_set_usleep(int n) +{ + int v; + + v = _async_task_usleep; + _async_task_usleep = n; + + return v; +} + /** * */ @@ -204,6 +218,7 @@ int async_task_run(int idx) LM_DBG("async task worker %d ready\n", idx); for( ; ; ) { + if(unlikely(_async_task_usleep)) sleep_us(_async_task_usleep); if ((received = recvfrom(_async_task_sockets[0], &ptask, sizeof(async_task_t*), 0, NULL, 0)) < 0) { diff --git a/async_task.h b/async_task.h index 321ad063c18..620009b4f64 100644 --- a/async_task.h +++ b/async_task.h @@ -36,5 +36,6 @@ int async_task_child_init(int rank); int async_task_initialized(void); int async_task_set_workers(int n); int async_task_push(async_task_t *task); +int async_task_set_usleep(int n); #endif diff --git a/cfg.lex b/cfg.lex index ef8c8816134..25468c73b74 100644 --- a/cfg.lex +++ b/cfg.lex @@ -400,6 +400,7 @@ SQL_BUFFER_SIZE sql_buffer_size CHILDREN children SOCKET_WORKERS socket_workers ASYNC_WORKERS async_workers +ASYNC_USLEEP async_usleep CHECK_VIA check_via PHONE2TEL phone2tel MEMLOG "memlog"|"mem_log" @@ -810,6 +811,7 @@ IMPORTFILE "import_file" {CHILDREN} { count(); yylval.strval=yytext; return CHILDREN; } {SOCKET_WORKERS} { count(); yylval.strval=yytext; return SOCKET_WORKERS; } {ASYNC_WORKERS} { count(); yylval.strval=yytext; return ASYNC_WORKERS; } +{ASYNC_USLEEP} { count(); yylval.strval=yytext; return ASYNC_USLEEP; } {CHECK_VIA} { count(); yylval.strval=yytext; return CHECK_VIA; } {PHONE2TEL} { count(); yylval.strval=yytext; return PHONE2TEL; } {MEMLOG} { count(); yylval.strval=yytext; return MEMLOG; } diff --git a/cfg.y b/cfg.y index 154cb445e02..06682a1cb92 100644 --- a/cfg.y +++ b/cfg.y @@ -446,6 +446,7 @@ extern char *default_routename; %token CHILDREN %token SOCKET_WORKERS %token ASYNC_WORKERS +%token ASYNC_USLEEP %token CHECK_VIA %token PHONE2TEL %token MEMLOG @@ -954,6 +955,8 @@ assign_stm: | SOCKET_WORKERS EQUAL error { yyerror("number expected"); } | ASYNC_WORKERS EQUAL NUMBER { async_task_set_workers($3); } | ASYNC_WORKERS EQUAL error { yyerror("number expected"); } + | ASYNC_USLEEP EQUAL NUMBER { async_task_set_usleep($3); } + | ASYNC_USLEEP 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; }