mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Stream: configurable socket buffer sizes.
The "rcvbuf" and "sndbuf" parameters are now supported by the "listen" directive.
This commit is contained in:
parent
97cb30370f
commit
9f7b557673
@ -494,6 +494,8 @@ ngx_stream_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
|
|||||||
ls->log.handler = ngx_accept_log_error;
|
ls->log.handler = ngx_accept_log_error;
|
||||||
|
|
||||||
ls->backlog = addr[i].opt.backlog;
|
ls->backlog = addr[i].opt.backlog;
|
||||||
|
ls->rcvbuf = addr[i].opt.rcvbuf;
|
||||||
|
ls->sndbuf = addr[i].opt.sndbuf;
|
||||||
|
|
||||||
ls->wildcard = addr[i].opt.wildcard;
|
ls->wildcard = addr[i].opt.wildcard;
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ typedef struct {
|
|||||||
int tcp_keepcnt;
|
int tcp_keepcnt;
|
||||||
#endif
|
#endif
|
||||||
int backlog;
|
int backlog;
|
||||||
|
int rcvbuf;
|
||||||
|
int sndbuf;
|
||||||
int type;
|
int type;
|
||||||
} ngx_stream_listen_t;
|
} ngx_stream_listen_t;
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
{
|
{
|
||||||
ngx_stream_core_srv_conf_t *cscf = conf;
|
ngx_stream_core_srv_conf_t *cscf = conf;
|
||||||
|
|
||||||
ngx_str_t *value;
|
ngx_str_t *value, size;
|
||||||
ngx_url_t u;
|
ngx_url_t u;
|
||||||
ngx_uint_t i, backlog;
|
ngx_uint_t i, backlog;
|
||||||
ngx_stream_listen_t *ls, *als;
|
ngx_stream_listen_t *ls, *als;
|
||||||
@ -620,6 +620,8 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
|
|
||||||
ls->socklen = u.socklen;
|
ls->socklen = u.socklen;
|
||||||
ls->backlog = NGX_LISTEN_BACKLOG;
|
ls->backlog = NGX_LISTEN_BACKLOG;
|
||||||
|
ls->rcvbuf = -1;
|
||||||
|
ls->sndbuf = -1;
|
||||||
ls->type = SOCK_STREAM;
|
ls->type = SOCK_STREAM;
|
||||||
ls->wildcard = u.wildcard;
|
ls->wildcard = u.wildcard;
|
||||||
ls->ctx = cf->ctx;
|
ls->ctx = cf->ctx;
|
||||||
@ -659,6 +661,38 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(value[i].data, "rcvbuf=", 7) == 0) {
|
||||||
|
size.len = value[i].len - 7;
|
||||||
|
size.data = value[i].data + 7;
|
||||||
|
|
||||||
|
ls->rcvbuf = ngx_parse_size(&size);
|
||||||
|
ls->bind = 1;
|
||||||
|
|
||||||
|
if (ls->rcvbuf == NGX_ERROR) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid rcvbuf \"%V\"", &value[i]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_strncmp(value[i].data, "sndbuf=", 7) == 0) {
|
||||||
|
size.len = value[i].len - 7;
|
||||||
|
size.data = value[i].data + 7;
|
||||||
|
|
||||||
|
ls->sndbuf = ngx_parse_size(&size);
|
||||||
|
ls->bind = 1;
|
||||||
|
|
||||||
|
if (ls->sndbuf == NGX_ERROR) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"invalid sndbuf \"%V\"", &value[i]);
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
|
if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
|
||||||
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
||||||
size_t len;
|
size_t len;
|
||||||
|
Loading…
Reference in New Issue
Block a user