comparison src/mail/ngx_mail_core_module.c @ 6976:6c13008ad503

Mail: configurable socket buffer sizes. The "rcvbuf" and "sndbuf" parameters are now supported by the "listen" directive.
author Vladimir Homutov <vl@nginx.com>
date Mon, 03 Apr 2017 17:30:34 +0300
parents cebf5fed00bf
children 7f955d3b9a0d
comparison
equal deleted inserted replaced
6975:d7ce41bdf050 6976:6c13008ad503
293 static char * 293 static char *
294 ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 294 ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
295 { 295 {
296 ngx_mail_core_srv_conf_t *cscf = conf; 296 ngx_mail_core_srv_conf_t *cscf = conf;
297 297
298 ngx_str_t *value; 298 ngx_str_t *value, size;
299 ngx_url_t u; 299 ngx_url_t u;
300 ngx_uint_t i, m; 300 ngx_uint_t i, m;
301 ngx_mail_listen_t *ls; 301 ngx_mail_listen_t *ls;
302 ngx_mail_module_t *module; 302 ngx_mail_module_t *module;
303 ngx_mail_core_main_conf_t *cmcf; 303 ngx_mail_core_main_conf_t *cmcf;
348 348
349 ngx_memcpy(&ls->sockaddr.sockaddr, &u.sockaddr, u.socklen); 349 ngx_memcpy(&ls->sockaddr.sockaddr, &u.sockaddr, u.socklen);
350 350
351 ls->socklen = u.socklen; 351 ls->socklen = u.socklen;
352 ls->backlog = NGX_LISTEN_BACKLOG; 352 ls->backlog = NGX_LISTEN_BACKLOG;
353 ls->rcvbuf = -1;
354 ls->sndbuf = -1;
353 ls->wildcard = u.wildcard; 355 ls->wildcard = u.wildcard;
354 ls->ctx = cf->ctx; 356 ls->ctx = cf->ctx;
355 357
356 #if (NGX_HAVE_INET6) 358 #if (NGX_HAVE_INET6)
357 ls->ipv6only = 1; 359 ls->ipv6only = 1;
390 ls->bind = 1; 392 ls->bind = 1;
391 393
392 if (ls->backlog == NGX_ERROR || ls->backlog == 0) { 394 if (ls->backlog == NGX_ERROR || ls->backlog == 0) {
393 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 395 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
394 "invalid backlog \"%V\"", &value[i]); 396 "invalid backlog \"%V\"", &value[i]);
397 return NGX_CONF_ERROR;
398 }
399
400 continue;
401 }
402
403 if (ngx_strncmp(value[i].data, "rcvbuf=", 7) == 0) {
404 size.len = value[i].len - 7;
405 size.data = value[i].data + 7;
406
407 ls->rcvbuf = ngx_parse_size(&size);
408 ls->bind = 1;
409
410 if (ls->rcvbuf == NGX_ERROR) {
411 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
412 "invalid rcvbuf \"%V\"", &value[i]);
413 return NGX_CONF_ERROR;
414 }
415
416 continue;
417 }
418
419 if (ngx_strncmp(value[i].data, "sndbuf=", 7) == 0) {
420 size.len = value[i].len - 7;
421 size.data = value[i].data + 7;
422
423 ls->sndbuf = ngx_parse_size(&size);
424 ls->bind = 1;
425
426 if (ls->sndbuf == NGX_ERROR) {
427 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
428 "invalid sndbuf \"%V\"", &value[i]);
395 return NGX_CONF_ERROR; 429 return NGX_CONF_ERROR;
396 } 430 }
397 431
398 continue; 432 continue;
399 } 433 }