comparison src/http/ngx_http_core_module.c @ 4474:41f640a693de

Time parsing cleanup. Nuke NGX_PARSE_LARGE_TIME, it's not used since 0.6.30. The only error ngx_parse_time() can currently return is NGX_ERROR, check it explicitly and make sure to cast it to appropriate type (either time_t or ngx_msec_t) to avoid signedness warnings on platforms with unsigned time_t (notably QNX).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 13 Feb 2012 15:41:11 +0000
parents c95b828912a3
children 7033faf6dc3c
comparison
equal deleted inserted replaced
4473:3b877a45d343 4474:41f640a693de
3851 3851
3852 if (p > s.data) { 3852 if (p > s.data) {
3853 s.len = p - s.data; 3853 s.len = p - s.data;
3854 3854
3855 lsopt.tcp_keepidle = ngx_parse_time(&s, 1); 3855 lsopt.tcp_keepidle = ngx_parse_time(&s, 1);
3856 if (lsopt.tcp_keepidle == NGX_ERROR) { 3856 if (lsopt.tcp_keepidle == (time_t) NGX_ERROR) {
3857 goto invalid_so_keepalive; 3857 goto invalid_so_keepalive;
3858 } 3858 }
3859 } 3859 }
3860 3860
3861 s.data = (p < end) ? (p + 1) : end; 3861 s.data = (p < end) ? (p + 1) : end;
3867 3867
3868 if (p > s.data) { 3868 if (p > s.data) {
3869 s.len = p - s.data; 3869 s.len = p - s.data;
3870 3870
3871 lsopt.tcp_keepintvl = ngx_parse_time(&s, 1); 3871 lsopt.tcp_keepintvl = ngx_parse_time(&s, 1);
3872 if (lsopt.tcp_keepintvl == NGX_ERROR) { 3872 if (lsopt.tcp_keepintvl == (time_t) NGX_ERROR) {
3873 goto invalid_so_keepalive; 3873 goto invalid_so_keepalive;
3874 } 3874 }
3875 } 3875 }
3876 3876
3877 s.data = (p < end) ? (p + 1) : end; 3877 s.data = (p < end) ? (p + 1) : end;
4514 4514
4515 s.len = value[i].len - 9; 4515 s.len = value[i].len - 9;
4516 s.data = value[i].data + 9; 4516 s.data = value[i].data + 9;
4517 4517
4518 inactive = ngx_parse_time(&s, 1); 4518 inactive = ngx_parse_time(&s, 1);
4519 if (inactive < 0) { 4519 if (inactive == (time_t) NGX_ERROR) {
4520 goto failed; 4520 goto failed;
4521 } 4521 }
4522 4522
4523 continue; 4523 continue;
4524 } 4524 }
4601 4601
4602 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) { 4602 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) {
4603 return "invalid value"; 4603 return "invalid value";
4604 } 4604 }
4605 4605
4606 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_PARSE_LARGE_TIME) {
4607 return "value must be less than 597 hours";
4608 }
4609
4610 if (cf->args->nelts == 2) { 4606 if (cf->args->nelts == 2) {
4611 return NGX_CONF_OK; 4607 return NGX_CONF_OK;
4612 } 4608 }
4613 4609
4614 clcf->keepalive_header = ngx_parse_time(&value[2], 1); 4610 clcf->keepalive_header = ngx_parse_time(&value[2], 1);
4615 4611
4616 if (clcf->keepalive_header == NGX_ERROR) { 4612 if (clcf->keepalive_header == (time_t) NGX_ERROR) {
4617 return "invalid value"; 4613 return "invalid value";
4618 }
4619
4620 if (clcf->keepalive_header == NGX_PARSE_LARGE_TIME) {
4621 return "value must be less than 68 years";
4622 } 4614 }
4623 4615
4624 return NGX_CONF_OK; 4616 return NGX_CONF_OK;
4625 } 4617 }
4626 4618