Skip to content

Commit

Permalink
Several TCP related params moved from core to TCP plain module.
Browse files Browse the repository at this point in the history
Moved from core to TCP module:
* tcp_max_msg_chunks
* tcp_crlf_pingpong
* tcp_crlf_drop
* tcp_async
* tcp_async_max_postponed_chunks
* tcp_async_local_connect_timeout
* tcp_async_local_write_timeout

The async support test moved from reactor into TCP-plain module.
  • Loading branch information
bogdan-iancu committed Feb 9, 2015
1 parent 1673663 commit 2922fcd
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 125 deletions.
16 changes: 0 additions & 16 deletions cfg.lex
Expand Up @@ -333,25 +333,18 @@ WDIR "workdir"|"wdir"
MHOMED mhomed
POLL_METHOD "poll_method"
DISABLE_TCP "disable_tcp"
ASYNC_TCP "tcp_async"
ASYNC_TCP_LOCAL_CON_TIMEOUT "tcp_async_local_connect_timeout"
ASYNC_TCP_LOCAL_WRITE_TIMEOUT "tcp_async_local_write_timeout"
ASYNC_TCP_MAX_POSTPONED_CHUNKS "tcp_async_max_postponed_chunks"
TCP_CHILDREN "tcp_children"
TCP_ACCEPT_ALIASES "tcp_accept_aliases"
TCP_SEND_TIMEOUT "tcp_send_timeout"
TCP_CONNECT_TIMEOUT "tcp_connect_timeout"
TCP_CON_LIFETIME "tcp_connection_lifetime"
TCP_LISTEN_BACKLOG "tcp_listen_backlog"
TCP_MAX_CONNECTIONS "tcp_max_connections"
TCP_OPT_CRLF_PINGPONG "tcp_crlf_pingpong"
TCP_OPT_CRLF_DROP "tcp_crlf_drop"
TCP_NO_NEW_CONN_BFLAG "tcp_no_new_conn_bflag"
TCP_KEEPALIVE "tcp_keepalive"
TCP_KEEPCOUNT "tcp_keepcount"
TCP_KEEPIDLE "tcp_keepidle"
TCP_KEEPINTERVAL "tcp_keepinterval"
TCP_MAX_MSG_CHUNKS "tcp_max_msg_chunks"
TCP_MAX_MSG_TIME "tcp_max_msg_time"
DISABLE_TLS "disable_tls"
TLSLOG "tlslog"|"tls_log"
Expand Down Expand Up @@ -641,16 +634,8 @@ IMPORTFILE "import_file"
<INITIAL>{CHROOT} { count(); yylval.strval=yytext; return CHROOT; }
<INITIAL>{WDIR} { count(); yylval.strval=yytext; return WDIR; }
<INITIAL>{MHOMED} { count(); yylval.strval=yytext; return MHOMED; }
<INITIAL>{TCP_OPT_CRLF_PINGPONG} { count(); yylval.strval=yytext; return TCP_OPT_CRLF_PINGPONG; }
<INITIAL>{TCP_OPT_CRLF_DROP} { count(); yylval.strval=yytext; return TCP_OPT_CRLF_DROP; }
<INITIAL>{TCP_NO_NEW_CONN_BFLAG} { count(); yylval.strval=yytext; return TCP_NO_NEW_CONN_BFLAG; }
<INITIAL>{DISABLE_TCP} { count(); yylval.strval=yytext; return DISABLE_TCP; }
<INITIAL>{ASYNC_TCP} { count(); yylval.strval=yytext; return ASYNC_TCP; }
<INITIAL>{ASYNC_TCP_LOCAL_CON_TIMEOUT} { count(); yylval.strval=yytext; return ASYNC_TCP_LOCAL_CON_TIMEOUT; }
<INITIAL>{ASYNC_TCP_LOCAL_WRITE_TIMEOUT} { count(); yylval.strval=yytext;
return ASYNC_TCP_LOCAL_WRITE_TIMEOUT; }
<INITIAL>{ASYNC_TCP_MAX_POSTPONED_CHUNKS} { count(); yylval.strval=yytext;
return ASYNC_TCP_MAX_POSTPONED_CHUNKS; }
<INITIAL>{TCP_CHILDREN} { count(); yylval.strval=yytext; return TCP_CHILDREN; }
<INITIAL>{TCP_ACCEPT_ALIASES} { count(); yylval.strval=yytext;
return TCP_ACCEPT_ALIASES; }
Expand All @@ -670,7 +655,6 @@ IMPORTFILE "import_file"
<INITIAL>{TCP_KEEPCOUNT} { count(); yylval.strval=yytext; return TCP_KEEPCOUNT; }
<INITIAL>{TCP_KEEPIDLE} { count(); yylval.strval=yytext; return TCP_KEEPIDLE; }
<INITIAL>{TCP_KEEPINTERVAL} { count(); yylval.strval=yytext; return TCP_KEEPINTERVAL; }
<INITIAL>{TCP_MAX_MSG_CHUNKS} { count(); yylval.strval=yytext; return TCP_MAX_MSG_CHUNKS; }
<INITIAL>{TCP_MAX_MSG_TIME} { count(); yylval.strval=yytext; return TCP_MAX_MSG_TIME; }
<INITIAL>{DISABLE_TLS} { count(); yylval.strval=yytext; return DISABLE_TLS; }
<INITIAL>{TLSLOG} { count(); yylval.strval=yytext; return TLS_PORT_NO; }
Expand Down
63 changes: 0 additions & 63 deletions cfg.y
Expand Up @@ -362,25 +362,18 @@ extern char *finame;
%token MHOMED
%token POLL_METHOD
%token DISABLE_TCP
%token ASYNC_TCP
%token ASYNC_TCP_LOCAL_CON_TIMEOUT
%token ASYNC_TCP_LOCAL_WRITE_TIMEOUT
%token ASYNC_TCP_MAX_POSTPONED_CHUNKS
%token TCP_ACCEPT_ALIASES
%token TCP_CHILDREN
%token TCP_CONNECT_TIMEOUT
%token TCP_SEND_TIMEOUT
%token TCP_CON_LIFETIME
%token TCP_LISTEN_BACKLOG
%token TCP_MAX_CONNECTIONS
%token TCP_OPT_CRLF_PINGPONG
%token TCP_OPT_CRLF_DROP
%token TCP_NO_NEW_CONN_BFLAG
%token TCP_KEEPALIVE
%token TCP_KEEPCOUNT
%token TCP_KEEPIDLE
%token TCP_KEEPINTERVAL
%token TCP_MAX_MSG_CHUNKS
%token TCP_MAX_MSG_TIME
%token DISABLE_TLS
%token TLSLOG
Expand Down Expand Up @@ -785,38 +778,6 @@ assign_stm: DEBUG EQUAL snumber {
#endif
}
| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
| ASYNC_TCP EQUAL NUMBER {
#ifdef USE_TCP
tcp_async=$3;
#else
warn("tcp support not compiled in");
#endif
}
| ASYNC_TCP EQUAL error { yyerror("boolean value expected"); }
| ASYNC_TCP_LOCAL_CON_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_async_local_connect_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
| ASYNC_TCP_LOCAL_CON_TIMEOUT EQUAL error { yyerror("boolean value expected"); }
| ASYNC_TCP_LOCAL_WRITE_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_async_local_write_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
| ASYNC_TCP_LOCAL_WRITE_TIMEOUT EQUAL error { yyerror("boolean value expected"); }
| ASYNC_TCP_MAX_POSTPONED_CHUNKS EQUAL NUMBER {
#ifdef USE_TCP
tcp_async_max_postponed_chunks=$3;
#else
warn("tcp support not compiled in");
#endif
}
| ASYNC_TCP_MAX_POSTPONED_CHUNKS EQUAL error { yyerror("boolean value expected"); }
| TCP_ACCEPT_ALIASES EQUAL NUMBER {
#ifdef USE_TCP
tcp_accept_aliases=$3;
Expand Down Expand Up @@ -873,22 +834,6 @@ assign_stm: DEBUG EQUAL snumber {
#endif
}
| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
| TCP_OPT_CRLF_PINGPONG EQUAL NUMBER {
#ifdef USE_TCP
tcp_crlf_pingpong=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_OPT_CRLF_PINGPONG EQUAL error { yyerror("boolean value expected"); }
| TCP_OPT_CRLF_DROP EQUAL NUMBER {
#ifdef USE_TCP
tcp_crlf_drop=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_OPT_CRLF_DROP EQUAL error { yyerror("boolean value expected"); }
| TCP_NO_NEW_CONN_BFLAG EQUAL NUMBER {
#ifdef USE_TCP
tmp = NULL;
Expand Down Expand Up @@ -922,14 +867,6 @@ assign_stm: DEBUG EQUAL snumber {
#endif
}
| TCP_KEEPALIVE EQUAL error { yyerror("boolean value expected"); }
| TCP_MAX_MSG_CHUNKS EQUAL NUMBER {
#ifdef USE_TCP
tcp_max_msg_chunks=$3;
#else
warn("tcp support not compiled in");
#endif
}
| TCP_MAX_MSG_CHUNKS EQUAL error { yyerror("boolean value expected"); }
| TCP_MAX_MSG_TIME EQUAL NUMBER {
#ifdef USE_TCP
tcp_max_msg_time=$3;
Expand Down
7 changes: 0 additions & 7 deletions globals.h
Expand Up @@ -76,18 +76,11 @@ extern int tcp_con_lifetime; /*!< connection lifetime */
extern int tcp_listen_backlog;
extern int tcp_max_fd_no;
extern int tcp_max_connections;
extern int tcp_crlf_pingpong;
extern int tcp_crlf_drop;
extern int tcp_keepalive;
extern int tcp_keepcount;
extern int tcp_keepidle;
extern int tcp_keepinterval;
extern int tcp_max_msg_chunks;
extern int tcp_max_msg_time;
extern int tcp_async;
extern int tcp_async_local_connect_timeout;
extern int tcp_async_local_write_timeout;
extern int tcp_async_max_postponed_chunks;
#endif
#ifdef USE_TLS
extern int tls_disable;
Expand Down
10 changes: 1 addition & 9 deletions io_wait.c
Expand Up @@ -523,7 +523,7 @@ enum poll_types get_poll_type(char* s)
* \param poll_method - poll method (0 for automatic best fit)
*/
int init_io_wait(io_wait_h* h, char *name, int max_fd,
enum poll_types poll_method, int async)
enum poll_types poll_method)
{
char * poll_err;

Expand Down Expand Up @@ -555,14 +555,6 @@ int init_io_wait(io_wait_h* h, char *name, int max_fd,

h->poll_method=poll_method;

if (h->poll_method != POLL_POLL && h->poll_method != POLL_EPOLL_LT &&
h->poll_method != POLL_EPOLL_ET) {
if (async)
LM_WARN("Tried to enable async polling but current poll method is %d."
" Currently we only support POLL and EPOLL \n",h->poll_method);
async=0;
}

/* common stuff, everybody has fd_hash */
h->fd_hash=local_malloc(sizeof(*(h->fd_hash))*h->max_fd_no);
if (h->fd_hash==0){
Expand Down
3 changes: 1 addition & 2 deletions io_wait.h
Expand Up @@ -85,7 +85,6 @@
#include <fcntl.h>

#include "dprint.h"
#include "globals.h" /* tcp_async */

#include "poll_types.h" /* poll_types*/
#ifdef HAVE_SIGIO_RT
Expand Down Expand Up @@ -704,7 +703,7 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx,
* \param poll_method poll method (0 for automatic best fit)
*/
int init_io_wait(io_wait_h* h, char *name, int max_fd,
enum poll_types poll_method, int async);
enum poll_types poll_method);

/*! \brief destroys everything init_io_wait allocated */
void destroy_io_wait(io_wait_h* h);
Expand Down
15 changes: 0 additions & 15 deletions main.c
Expand Up @@ -178,26 +178,11 @@ enum poll_types io_poll_method=0; /*!< by default choose the best method */
#ifdef USE_TCP
int tcp_children_no = 0;
int tcp_disable = 0; /* 1 if tcp is disabled */
int tcp_crlf_pingpong = 1; /* 0: send CRLF pong to incoming CRLFCRLF ping */
int tcp_crlf_drop = 0; /* 0: do not drop single CRLF messages */
int tcp_max_msg_time = TCP_CHILD_MAX_MSG_TIME; /* Max number of seconds that
we except a full SIP message
to arrive in - anything above
will lead to the connection to
closed */
int tcp_async = 0; /* 1 if TCP connect & write should be async */
int tcp_async_local_connect_timeout = 10000; /* Number of microseconds that a
worker will block waiting for a local
connect - if connect op exceeds this, it
will get passed to TCP main*/
int tcp_async_local_write_timeout = 10000; /* Number of microseconds that a
worker will block waiting for a local
write - if write op exceeds this, it
will get passed to TCP main*/
int tcp_async_max_postponed_chunks = 32; /* maximum number of write chunks that
will be queued per TCP connection -
if we exceed this number, we just
drop the connection */
#endif
#ifdef USE_TLS
int tls_disable = 1; /* 1 if tls is disabled */
Expand Down
11 changes: 8 additions & 3 deletions net/net_tcp.c
Expand Up @@ -597,7 +597,7 @@ int tcpconn_add_alias(int id, int port, int proto)

a=0;
/* fix the port */
port=port ? port : protos[proto].default_port ;
port=port ? port : protos[proto].api.default_port ;
TCPCONN_LOCK(id);
/* check if alias already exists */
c=_tcpconn_find(id);
Expand Down Expand Up @@ -1353,7 +1353,7 @@ void tcp_main_server(void)

/* we run in a separate, dedicated process, with its own reactor
* (reactors are per process) */
if (init_worker_reactor("TCP_main", tcp_max_fd_no, tcp_async)<0)
if (init_worker_reactor("TCP_main", tcp_max_fd_no)<0)
goto error;

/* now start watching all the fds*/
Expand Down Expand Up @@ -1624,7 +1624,7 @@ int tcp_start_processes(int *chd_rank, int *startup_done)

report_conditional_status( (1), 0);

tcp_worker_proc( reader_fd[1], tcp_max_fd_no, tcp_async);
tcp_worker_proc( reader_fd[1], tcp_max_fd_no);
exit(-1);
}
}
Expand Down Expand Up @@ -1656,6 +1656,11 @@ int tcp_start_processes(int *chd_rank, int *startup_done)
return -1;
}

int tcp_has_async_write(void)
{
return reactor_has_async();
}


/***************************** MI functions **********************************/

Expand Down
3 changes: 3 additions & 0 deletions net/net_tcp.h
Expand Up @@ -39,6 +39,9 @@ int tcp_init(void);
/* destroys the TCP data */
void tcp_destroy(void);

/* checks if the TCP layer may provide async write support */
int tcp_has_async_write(void);

/* creates the communication channel between a generic OpenSIPS process
and the TCP MAIN process - TO BE called before forking */
int tcp_pre_connect_proc_to_tcp_main(void);
Expand Down
4 changes: 2 additions & 2 deletions net/net_tcp_proc.c
Expand Up @@ -255,11 +255,11 @@ static inline void tcp_receive_timeout(void)



void tcp_worker_proc( int unix_sock, int max_fd, int async )
void tcp_worker_proc( int unix_sock, int max_fd )
{
/* init reactor for TCP worker */
tcpmain_sock=unix_sock; /* init com. socket */
if ( init_worker_reactor( "TCP_worker", max_fd, async)<0 ) {
if ( init_worker_reactor( "TCP_worker", max_fd)<0 ) {
goto error;
}

Expand Down
2 changes: 1 addition & 1 deletion net/net_tcp_proc.h
Expand Up @@ -27,6 +27,6 @@
#define _NET_net_tcp_proc_h

/* Loop implementing a TCP worker */
void tcp_worker_proc( int fd, int max_fd, int async);
void tcp_worker_proc( int fd, int max_fd);

#endif

0 comments on commit 2922fcd

Please sign in to comment.