Skip to content

Commit

Permalink
Re-order TCP related parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Feb 19, 2015
1 parent 172eea3 commit 8becb75
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 164 deletions.
2 changes: 0 additions & 2 deletions cfg.lex
Expand Up @@ -331,7 +331,6 @@ CHROOT "chroot"
WDIR "workdir"|"wdir"
MHOMED mhomed
POLL_METHOD "poll_method"
DISABLE_TCP "disable_tcp"
TCP_CHILDREN "tcp_children"
TCP_ACCEPT_ALIASES "tcp_accept_aliases"
TCP_SEND_TIMEOUT "tcp_send_timeout"
Expand Down Expand Up @@ -610,7 +609,6 @@ IMPORTFILE "import_file"
<INITIAL>{WDIR} { count(); yylval.strval=yytext; return WDIR; }
<INITIAL>{MHOMED} { count(); yylval.strval=yytext; return MHOMED; }
<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>{TCP_CHILDREN} { count(); yylval.strval=yytext; return TCP_CHILDREN; }
<INITIAL>{TCP_ACCEPT_ALIASES} { count(); yylval.strval=yytext;
return TCP_ACCEPT_ALIASES; }
Expand Down
131 changes: 35 additions & 96 deletions cfg.y
Expand Up @@ -354,7 +354,6 @@ extern char *finame;
%token WDIR
%token MHOMED
%token POLL_METHOD
%token DISABLE_TCP
%token TCP_ACCEPT_ALIASES
%token TCP_CHILDREN
%token TCP_CONNECT_TIMEOUT
Expand Down Expand Up @@ -727,101 +726,53 @@ assign_stm: DEBUG EQUAL snumber {
}
}
| POLL_METHOD EQUAL error { yyerror("poll method name expected"); }
| DISABLE_TCP EQUAL NUMBER {
#ifdef USE_TCP
tcp_disable=$3;
#else
warn("tcp support not compiled in");
#endif
}
| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
| TCP_ACCEPT_ALIASES EQUAL NUMBER {
#ifdef USE_TCP
tcp_accept_aliases=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_accept_aliases=$3;
}
| TCP_ACCEPT_ALIASES EQUAL error { yyerror("boolean value expected"); }
| TCP_CHILDREN EQUAL NUMBER {
#ifdef USE_TCP
tcp_children_no=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_children_no=$3;
}
| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
| TCP_CONNECT_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_connect_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_connect_timeout=$3;
}
| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_SEND_TIMEOUT EQUAL NUMBER {
#ifdef USE_TCP
tcp_send_timeout=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_send_timeout=$3;
}
| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
| TCP_CON_LIFETIME EQUAL NUMBER {
#ifdef USE_TCP
tcp_con_lifetime=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_con_lifetime=$3;
}
| TCP_CON_LIFETIME EQUAL error { yyerror("number expected"); }
| TCP_LISTEN_BACKLOG EQUAL NUMBER {
#ifdef USE_TCP
tcp_listen_backlog=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_listen_backlog=$3;
}
| TCP_LISTEN_BACKLOG EQUAL error { yyerror("number expected"); }
| TCP_MAX_CONNECTIONS EQUAL NUMBER {
#ifdef USE_TCP
tcp_max_connections=$3;
#else
warn("tcp support not compiled in");
#endif
}
tcp_max_connections=$3;
}
| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
| TCP_NO_NEW_CONN_BFLAG EQUAL NUMBER {
#ifdef USE_TCP
tmp = NULL;
fix_flag_name(tmp, $3);
// FIXME TCP - this flag should be in proto level now
//tcp_no_new_conn_bflag = get_flag_id_by_name(FLAG_TYPE_BRANCH, tmp);
//if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
// yyerror("invalid TCP no_new_conn Branch Flag");
//flag_idx2mask( &tcp_no_new_conn_bflag );
#else
warn("tcp support not compiled in");
#endif
tcp_no_new_conn_bflag =
get_flag_id_by_name(FLAG_TYPE_BRANCH, tmp);
if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
yyerror("invalid TCP no_new_conn Branch Flag");
flag_idx2mask( &tcp_no_new_conn_bflag );
}
| TCP_NO_NEW_CONN_BFLAG EQUAL ID {
#ifdef USE_TCP
// FIXME TCP
//tcp_no_new_conn_bflag = get_flag_id_by_name(FLAG_TYPE_BRANCH, $3);
//if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
// yyerror("invalid TCP no_new_conn Branch Flag");
//flag_idx2mask( &tcp_no_new_conn_bflag );
#else
warn("tcp support not compiled in");
#endif
tcp_no_new_conn_bflag =
get_flag_id_by_name(FLAG_TYPE_BRANCH, $3);
if (!flag_in_range( (flag_t)tcp_no_new_conn_bflag ) )
yyerror("invalid TCP no_new_conn Branch Flag");
flag_idx2mask( &tcp_no_new_conn_bflag );
}
| TCP_NO_NEW_CONN_BFLAG EQUAL error { yyerror("number value expected"); }
| TCP_KEEPALIVE EQUAL NUMBER {
#ifdef USE_TCP
tcp_keepalive=$3;
#else
warn("tcp support not compiled in");
#endif
tcp_keepalive=$3;
}
| TCP_KEEPALIVE EQUAL error { yyerror("boolean value expected"); }
| TCP_MAX_MSG_TIME EQUAL NUMBER {
Expand All @@ -833,39 +784,27 @@ assign_stm: DEBUG EQUAL snumber {
}
| TCP_MAX_MSG_TIME EQUAL error { yyerror("boolean value expected"); }
| TCP_KEEPCOUNT EQUAL NUMBER {
#ifdef USE_TCP
#ifndef HAVE_TCP_KEEPCNT
#ifndef HAVE_TCP_KEEPCNT
warn("cannot be enabled (no OS support)");
#else
tcp_keepcount=$3;
#endif
#else
warn("tcp support not compiled in");
#else
tcp_keepcount=$3;
#endif
}
| TCP_KEEPCOUNT EQUAL error { yyerror("int value expected"); }
| TCP_KEEPIDLE EQUAL NUMBER {
#ifdef USE_TCP
#ifndef HAVE_TCP_KEEPIDLE
#ifndef HAVE_TCP_KEEPIDLE
warn("cannot be enabled (no OS support)");
#else
tcp_keepidle=$3;
#endif
#else
warn("tcp support not compiled in");
#else
tcp_keepidle=$3;
#endif
}
| TCP_KEEPIDLE EQUAL error { yyerror("int value expected"); }
| TCP_KEEPINTERVAL EQUAL NUMBER {
#ifdef USE_TCP
#ifndef HAVE_TCP_KEEPINTVL
#ifndef HAVE_TCP_KEEPINTVL
warn("cannot be enabled (no OS support)");
#else
tcp_keepinterval=$3;
#endif
#else
warn("tcp support not compiled in");
#endif
#else
tcp_keepinterval=$3;
#endif
}
| TCP_KEEPINTERVAL EQUAL error { yyerror("int value expected"); }
| SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
Expand Down
17 changes: 4 additions & 13 deletions forward.c
Expand Up @@ -350,11 +350,8 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
hostent2su( &to, &p->host, p->addr_idx, (p->port)?p->port:SIP_PORT);
last_sock = 0;

#ifdef USE_TCP
// FIXME TCP
//if (getb0flags(msg) & tcp_no_new_conn_bflag)
// tcp_no_new_conn = 1;
#endif
if (getb0flags(msg) & tcp_no_new_conn_bflag)
tcp_no_new_conn = 1;

do {
send_sock=get_send_socket( msg, &to, p->proto);
Expand All @@ -373,10 +370,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
buf = build_req_buf_from_sip_req(msg, &len, send_sock, p->proto, 0);
if (!buf){
LM_ERR("building req buf failed\n");
#ifdef USE_TCP
// FIXME TCP
//tcp_no_new_conn = 0;
#endif
tcp_no_new_conn = 0;
goto error;
}

Expand Down Expand Up @@ -406,10 +400,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)

}while( get_next_su( p, &to, (ser_error==E_IP_BLOCKED)?0:1)==0 );

#ifdef USE_TCP
// FIXME TCP
//tcp_no_new_conn = 0;
#endif
tcp_no_new_conn = 0;

if (ser_error) {
update_stat( drp_reqs, 1);
Expand Down
7 changes: 4 additions & 3 deletions globals.h
Expand Up @@ -48,7 +48,8 @@ extern int auto_aliases;
extern unsigned int maxbuffer;
extern int children_no;
extern enum poll_types io_poll_method;
#ifdef USE_TCP

/* TCP network layer related parameters */
extern int tcp_children_no;
extern int tcp_disable;
extern int tcp_accept_aliases;
Expand All @@ -63,9 +64,9 @@ extern int tcp_keepcount;
extern int tcp_keepidle;
extern int tcp_keepinterval;
extern int tcp_max_msg_time;
extern int tcp_no_new_conn; // FIXME TCP - to be removed
extern int tcp_no_new_conn;
extern int tcp_no_new_conn_bflag;
#endif

extern int dont_fork;
extern int no_daemon_mode;
extern int check_via;
Expand Down
30 changes: 1 addition & 29 deletions main.c
Expand Up @@ -166,17 +166,8 @@ unsigned int maxbuffer = MAX_RECV_BUFFER_SIZE; /* maximum buffer size we do
not want to exceed during the
auto-probing procedure; may
be re-configured */
int children_no = 0; /* number of children processing requests */
int children_no = CHILD_NO; /* number of children processing requests */
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_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 */
#endif
int sig_flag = 0; /* last signal received */

int dont_fork = 0;
Expand Down Expand Up @@ -942,24 +933,12 @@ int main(int argc, char** argv)
case 'E':
cfg_log_stderr=1;
break;
case 'T':
#ifdef USE_TCP
tcp_disable=1;
#else
LM_WARN("tcp support not compiled in\n");
#endif
break;
break;
case 'N':
#ifdef USE_TCP
tcp_children_no=strtol(optarg, &tmp, 10);
if ((tmp==0) ||(*tmp)){
LM_ERR("bad process number: -N %s\n", optarg);
goto error00;
}
#else
LM_WARN("tcp support not compiled in\n");
#endif
break;
case 'W':
io_poll_method=get_poll_type(optarg);
Expand Down Expand Up @@ -1120,13 +1099,6 @@ int main(int argc, char** argv)
}

/* fix parameters */
if (children_no<=0) children_no=CHILD_NO;
#ifdef USE_TCP
if (!tcp_disable){
if (tcp_children_no<=0) tcp_children_no=children_no;
}
#endif

if (working_dir==0) working_dir="/";

/* get uid/gid */
Expand Down
7 changes: 3 additions & 4 deletions modules/proto_tls/proto_tls.c
Expand Up @@ -1185,10 +1185,9 @@ static int proto_tls_send(struct socket_info* send_sock,

/* was connection found ?? */
if (c==0) {
// FIXME
//if (tcp_no_new_conn) {
// return -1;
//}
if (tcp_no_new_conn) {
return -1;
}
LM_DBG("no open tcp connection found, opening new one\n");
/* create tcp connection */
if ((c=tls_sync_connect(send_sock, to))==0) {
Expand Down
4 changes: 0 additions & 4 deletions modules/tm/t_fwd.c
Expand Up @@ -661,10 +661,8 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
for (i=t->first_branch; i<t->nr_of_outgoings; i++) {
if (added_branches & (1<<i)) {

#ifdef USE_TCP
if (t->uac[i].br_flags & tcp_no_new_conn_bflag)
tcp_no_new_conn = 1;
#endif

do {
if (check_blacklists( t->uac[i].request.dst.proto,
Expand Down Expand Up @@ -695,9 +693,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
break;
}while(1);

#ifdef USE_TCP
tcp_no_new_conn = 0;
#endif

if (ser_error) {
shm_free(t->uac[i].request.buffer.s);
Expand Down

0 comments on commit 8becb75

Please sign in to comment.