comparison src/http/ngx_http_core_module.c @ 4323:c4513d4dd024

Added the "so_keepalive=" parameter to the "listen" directive. The "so_keepalive" directive in mail module was deprecated. Thanks to Vsevolod Stakhov for initial work.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 05 Dec 2011 08:06:15 +0000
parents 986be4081f71
children b278e6e514fd
comparison
equal deleted inserted replaced
4322:acd8d267f557 4323:c4513d4dd024
3813 "ngx_http_ssl_module"); 3813 "ngx_http_ssl_module");
3814 return NGX_CONF_ERROR; 3814 return NGX_CONF_ERROR;
3815 #endif 3815 #endif
3816 } 3816 }
3817 3817
3818 if (ngx_strncmp(value[n].data, "so_keepalive=", 13) == 0) {
3819
3820 if (ngx_strcmp(&value[n].data[13], "on") == 0) {
3821 lsopt.so_keepalive = 1;
3822
3823 } else if (ngx_strcmp(&value[n].data[13], "off") == 0) {
3824 lsopt.so_keepalive = 2;
3825
3826 } else {
3827
3828 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
3829 u_char *p, *end;
3830 ngx_str_t s;
3831
3832 end = value[n].data + value[n].len;
3833 s.data = value[n].data + 13;
3834
3835 p = ngx_strlchr(s.data, end, ':');
3836 if (p == NULL) {
3837 p = end;
3838 }
3839
3840 if (p > s.data) {
3841 s.len = p - s.data;
3842
3843 lsopt.tcp_keepidle = ngx_parse_time(&s, 1);
3844 if (lsopt.tcp_keepidle == NGX_ERROR) {
3845 goto invalid_so_keepalive;
3846 }
3847 }
3848
3849 s.data = (p < end) ? (p + 1) : end;
3850
3851 p = ngx_strlchr(s.data, end, ':');
3852 if (p == NULL) {
3853 p = end;
3854 }
3855
3856 if (p > s.data) {
3857 s.len = p - s.data;
3858
3859 lsopt.tcp_keepintvl = ngx_parse_time(&s, 1);
3860 if (lsopt.tcp_keepintvl == NGX_ERROR) {
3861 goto invalid_so_keepalive;
3862 }
3863 }
3864
3865 s.data = (p < end) ? (p + 1) : end;
3866
3867 if (s.data < end) {
3868 s.len = end - s.data;
3869
3870 lsopt.tcp_keepcnt = ngx_atoi(s.data, s.len);
3871 if (lsopt.tcp_keepcnt == NGX_ERROR) {
3872 goto invalid_so_keepalive;
3873 }
3874 }
3875
3876 if (lsopt.tcp_keepidle == 0 && lsopt.tcp_keepintvl == 0
3877 && lsopt.tcp_keepcnt == 0)
3878 {
3879 goto invalid_so_keepalive;
3880 }
3881
3882 lsopt.so_keepalive = 1;
3883
3884 #else
3885
3886 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3887 "the \"so_keepalive\" parameter accepts "
3888 "only \"on\" or \"off\" on this platform");
3889 return NGX_CONF_ERROR;
3890
3891 #endif
3892 }
3893
3894 lsopt.set = 1;
3895 lsopt.bind = 1;
3896
3897 continue;
3898
3899 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
3900 invalid_so_keepalive:
3901
3902 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3903 "invalid so_keepalive value: \"%s\"",
3904 &value[n].data[13]);
3905 return NGX_CONF_ERROR;
3906 #endif
3907 }
3908
3818 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3909 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3819 "invalid parameter \"%V\"", &value[n]); 3910 "invalid parameter \"%V\"", &value[n]);
3820 return NGX_CONF_ERROR; 3911 return NGX_CONF_ERROR;
3821 } 3912 }
3822 3913