Mercurial > hg > nginx
comparison src/http/ngx_http_file_cache.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 | d620f497c50f |
children | 95ab6658654a |
comparison
equal
deleted
inserted
replaced
4473:3b877a45d343 | 4474:41f640a693de |
---|---|
1595 off_t max_size; | 1595 off_t max_size; |
1596 u_char *last, *p; | 1596 u_char *last, *p; |
1597 time_t inactive; | 1597 time_t inactive; |
1598 ssize_t size; | 1598 ssize_t size; |
1599 ngx_str_t s, name, *value; | 1599 ngx_str_t s, name, *value; |
1600 ngx_int_t loader_files, loader_sleep, loader_threshold; | 1600 ngx_int_t loader_files; |
1601 ngx_msec_t loader_sleep, loader_threshold; | |
1601 ngx_uint_t i, n; | 1602 ngx_uint_t i, n; |
1602 ngx_http_file_cache_t *cache; | 1603 ngx_http_file_cache_t *cache; |
1603 | 1604 |
1604 cache = ngx_pcalloc(cf->pool, sizeof(ngx_http_file_cache_t)); | 1605 cache = ngx_pcalloc(cf->pool, sizeof(ngx_http_file_cache_t)); |
1605 if (cache == NULL) { | 1606 if (cache == NULL) { |
1702 | 1703 |
1703 s.len = value[i].len - 9; | 1704 s.len = value[i].len - 9; |
1704 s.data = value[i].data + 9; | 1705 s.data = value[i].data + 9; |
1705 | 1706 |
1706 inactive = ngx_parse_time(&s, 1); | 1707 inactive = ngx_parse_time(&s, 1); |
1707 if (inactive < 0) { | 1708 if (inactive == (time_t) NGX_ERROR) { |
1708 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1709 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1709 "invalid inactive value \"%V\"", &value[i]); | 1710 "invalid inactive value \"%V\"", &value[i]); |
1710 return NGX_CONF_ERROR; | 1711 return NGX_CONF_ERROR; |
1711 } | 1712 } |
1712 | 1713 |
1744 | 1745 |
1745 s.len = value[i].len - 13; | 1746 s.len = value[i].len - 13; |
1746 s.data = value[i].data + 13; | 1747 s.data = value[i].data + 13; |
1747 | 1748 |
1748 loader_sleep = ngx_parse_time(&s, 0); | 1749 loader_sleep = ngx_parse_time(&s, 0); |
1749 if (loader_sleep < 0) { | 1750 if (loader_sleep == (ngx_msec_t) NGX_ERROR) { |
1750 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1751 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1751 "invalid loader_sleep value \"%V\"", &value[i]); | 1752 "invalid loader_sleep value \"%V\"", &value[i]); |
1752 return NGX_CONF_ERROR; | 1753 return NGX_CONF_ERROR; |
1753 } | 1754 } |
1754 | 1755 |
1759 | 1760 |
1760 s.len = value[i].len - 17; | 1761 s.len = value[i].len - 17; |
1761 s.data = value[i].data + 17; | 1762 s.data = value[i].data + 17; |
1762 | 1763 |
1763 loader_threshold = ngx_parse_time(&s, 0); | 1764 loader_threshold = ngx_parse_time(&s, 0); |
1764 if (loader_threshold < 0) { | 1765 if (loader_threshold == (ngx_msec_t) NGX_ERROR) { |
1765 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1766 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1766 "invalid loader_threshold value \"%V\"", &value[i]); | 1767 "invalid loader_threshold value \"%V\"", &value[i]); |
1767 return NGX_CONF_ERROR; | 1768 return NGX_CONF_ERROR; |
1768 } | 1769 } |
1769 | 1770 |
1786 cache->path->loader = ngx_http_file_cache_loader; | 1787 cache->path->loader = ngx_http_file_cache_loader; |
1787 cache->path->data = cache; | 1788 cache->path->data = cache; |
1788 cache->path->conf_file = cf->conf_file->file.name.data; | 1789 cache->path->conf_file = cf->conf_file->file.name.data; |
1789 cache->path->line = cf->conf_file->line; | 1790 cache->path->line = cf->conf_file->line; |
1790 cache->loader_files = loader_files; | 1791 cache->loader_files = loader_files; |
1791 cache->loader_sleep = (ngx_msec_t) loader_sleep; | 1792 cache->loader_sleep = loader_sleep; |
1792 cache->loader_threshold = (ngx_msec_t) loader_threshold; | 1793 cache->loader_threshold = loader_threshold; |
1793 | 1794 |
1794 if (ngx_add_path(cf, &cache->path) != NGX_OK) { | 1795 if (ngx_add_path(cf, &cache->path) != NGX_OK) { |
1795 return NGX_CONF_ERROR; | 1796 return NGX_CONF_ERROR; |
1796 } | 1797 } |
1797 | 1798 |
1841 | 1842 |
1842 value = cf->args->elts; | 1843 value = cf->args->elts; |
1843 n = cf->args->nelts - 1; | 1844 n = cf->args->nelts - 1; |
1844 | 1845 |
1845 valid = ngx_parse_time(&value[n], 1); | 1846 valid = ngx_parse_time(&value[n], 1); |
1846 if (valid < 0) { | 1847 if (valid == (time_t) NGX_ERROR) { |
1847 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1848 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1848 "invalid time value \"%V\"", &value[n]); | 1849 "invalid time value \"%V\"", &value[n]); |
1849 return NGX_CONF_ERROR; | 1850 return NGX_CONF_ERROR; |
1850 } | 1851 } |
1851 | 1852 |