Module: sip-router Branch: master Commit: 691a34390725b4a84d50d12b76bcb69c32a50071 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=691a3439...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Jan 6 11:42:10 2012 +0100
core: new cfg global parameter tcp_clone_rcvbuf
- control cloning of tcp receive buffer, default is 0 (no cloning), set to 1 for cloning
---
cfg.lex | 3 +++ cfg.y | 9 +++++++++ tcp_options.h | 4 ++++ tcp_read.c | 21 ++++++++++++++++++++- 4 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/cfg.lex b/cfg.lex index 26e31d0..0f1be4c 100644 --- a/cfg.lex +++ b/cfg.lex @@ -434,6 +434,7 @@ TCP_OPT_KEEPINTVL "tcp_keepintvl" TCP_OPT_KEEPCNT "tcp_keepcnt" TCP_OPT_CRLF_PING "tcp_crlf_ping" TCP_OPT_ACCEPT_NO_CL "tcp_accept_no_cl" +TCP_CLONE_RCVBUF "tcp_clone_rcvbuf" DISABLE_TLS "disable_tls"|"tls_disable" ENABLE_TLS "enable_tls"|"tls_enable" TLSLOG "tlslog"|"tls_log" @@ -846,6 +847,8 @@ IMPORTFILE "import_file" return TCP_OPT_CRLF_PING; } <INITIAL>{TCP_OPT_ACCEPT_NO_CL} { count(); yylval.strval=yytext; return TCP_OPT_ACCEPT_NO_CL; } +<INITIAL>{TCP_CLONE_RCVBUF} { count(); yylval.strval=yytext; + return TCP_CLONE_RCVBUF; } <INITIAL>{DISABLE_TLS} { count(); yylval.strval=yytext; return DISABLE_TLS; } <INITIAL>{ENABLE_TLS} { count(); yylval.strval=yytext; return ENABLE_TLS; } <INITIAL>{TLSLOG} { count(); yylval.strval=yytext; return TLS_PORT_NO; } diff --git a/cfg.y b/cfg.y index dcca98e..fb494ea 100644 --- a/cfg.y +++ b/cfg.y @@ -492,6 +492,7 @@ extern char *finame; %token TCP_OPT_KEEPCNT %token TCP_OPT_CRLF_PING %token TCP_OPT_ACCEPT_NO_CL +%token TCP_CLONE_RCVBUF %token DISABLE_TLS %token ENABLE_TLS %token TLSLOG @@ -1232,6 +1233,14 @@ assign_stm: #endif } | TCP_OPT_ACCEPT_NO_CL EQUAL error { yyerror("boolean value expected"); } + | TCP_CLONE_RCVBUF EQUAL NUMBER { + #ifdef USE_TCP + tcp_set_clone_rcvbuf($3); + #else + warn("tcp support not compiled in"); + #endif + } + | TCP_CLONE_RCVBUF EQUAL error { yyerror("number expected"); } | DISABLE_TLS EQUAL NUMBER { #ifdef USE_TLS tls_disable=$3; diff --git a/tcp_options.h b/tcp_options.h index f9a4e64..1c0ed24 100644 --- a/tcp_options.h +++ b/tcp_options.h @@ -157,4 +157,8 @@ void tcp_options_check(); int tcp_register_cfg(); void tcp_options_get(struct cfg_group_tcp* t);
+#ifdef USE_TCP +int tcp_set_clone_rcvbuf(int v); +#endif /* USE_TCP */ + #endif /* tcp_options_h */ diff --git a/tcp_read.c b/tcp_read.c index c86a2dd..dde2f94 100644 --- a/tcp_read.c +++ b/tcp_read.c @@ -121,6 +121,22 @@ static int tcpmain_sock=-1; static struct local_timer tcp_reader_ltimer; static ticks_t tcp_reader_prev_ticks;
+/** + * control cloning of TCP receive buffer + * - needed for operations working directly inside the buffer + * (like msg_apply_changes()) + */ +#define TCP_CLONE_RCVBUF +static int tcp_clone_rcvbuf = 0; + +int tcp_set_clone_rcvbuf(int v) +{ + int r; + r = tcp_clone_rcvbuf; + tcp_clone_rcvbuf = v; + return r; +} + #ifdef READ_HTTP11 static inline char *strfindcasestrz(str *haystack, char *needlez) { @@ -856,7 +872,6 @@ skip: * the content of the stream. Safer, make a clone of buf content in a local * buffer and give that to receive_msg() to link to msg->buf */ -#define TCP_CLONE_RCVBUF int receive_tcp_msg(char* tcpbuf, unsigned int len, struct receive_info* rcv_info) { #ifdef TCP_CLONE_RCVBUF @@ -868,6 +883,10 @@ int receive_tcp_msg(char* tcpbuf, unsigned int len, struct receive_info* rcv_inf #endif int blen;
+ /* cloning is disabled via parameter */ + if(likely(tcp_clone_rcvbuf==0)) + return receive_msg(tcpbuf, len, rcv_info); + /* min buffer size is BUF_SIZE */ blen = len; if(blen < BUF_SIZE)