aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2017-04-03 17:30:34 +0300
committerVladimir Homutov <vl@nginx.com>2017-04-03 17:30:34 +0300
commita965e1d76642095f3f4e5f43d13a8b0379296e43 (patch)
treecbe27ab348d141c84299d77045c57ab011b65590 /src
parent9f7b5576735d1a711acfc62af45088a54c786d27 (diff)
downloadnginx-a965e1d76642095f3f4e5f43d13a8b0379296e43.tar.gz
nginx-a965e1d76642095f3f4e5f43d13a8b0379296e43.zip
Mail: configurable socket buffer sizes.
The "rcvbuf" and "sndbuf" parameters are now supported by the "listen" directive.
Diffstat (limited to 'src')
-rw-r--r--src/mail/ngx_mail.c2
-rw-r--r--src/mail/ngx_mail.h2
-rw-r--r--src/mail/ngx_mail_core_module.c36
3 files changed, 39 insertions, 1 deletions
diff --git a/src/mail/ngx_mail.c b/src/mail/ngx_mail.c
index 9e560bb7c..5fd5fa00c 100644
--- a/src/mail/ngx_mail.c
+++ b/src/mail/ngx_mail.c
@@ -333,6 +333,8 @@ ngx_mail_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports)
ls->log.handler = ngx_accept_log_error;
ls->backlog = addr[i].opt.backlog;
+ ls->rcvbuf = addr[i].opt.rcvbuf;
+ ls->sndbuf = addr[i].opt.sndbuf;
ls->keepalive = addr[i].opt.so_keepalive;
#if (NGX_HAVE_KEEPALIVE_TUNABLE)
diff --git a/src/mail/ngx_mail.h b/src/mail/ngx_mail.h
index 600250820..6ecfefc98 100644
--- a/src/mail/ngx_mail.h
+++ b/src/mail/ngx_mail.h
@@ -46,6 +46,8 @@ typedef struct {
int tcp_keepcnt;
#endif
int backlog;
+ int rcvbuf;
+ int sndbuf;
} ngx_mail_listen_t;
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
index b974d905c..276b8eeb1 100644
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -295,7 +295,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_mail_core_srv_conf_t *cscf = conf;
- ngx_str_t *value;
+ ngx_str_t *value, size;
ngx_url_t u;
ngx_uint_t i, m;
ngx_mail_listen_t *ls;
@@ -350,6 +350,8 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ls->socklen = u.socklen;
ls->backlog = NGX_LISTEN_BACKLOG;
+ ls->rcvbuf = -1;
+ ls->sndbuf = -1;
ls->wildcard = u.wildcard;
ls->ctx = cf->ctx;
@@ -398,6 +400,38 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
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_HAVE_INET6 && defined IPV6_V6ONLY)
size_t len;