ngx_parse_time not handling seconds flag properly?

Igor Sysoev is at rambler-co.ru
Wed Jan 28 09:43:11 MSK 2009


On Tue, Jan 27, 2009 at 07:29:58PM -0800, Mike Smith wrote:

> It looks to me like ngx_parse_time is scaling to seconds when you
> don't want it and not scaling when you do. When called from
> ngx_conf_set_msec_slot, it scales all msec values up by a factor of
> 1000, so if I want a timeout of 180ms I actually get a timeout of
> 180s.
> 
> Can anyone comment on this.

nginx works internally with millisecond resolution.
So ngx_parse_time(..., 0) returns parsed time in milliseconds.
There are some places where seconds are enough, for these
ngx_parse_time(..., 1) returns parsed time in seconds.

> Thanks,
> Mike
> 
> Index: src/core/ngx_parse.c
> ===================================================================
> --- src/core/ngx_parse.c	(.../tags/nginx-0.7.32)	(revision 15961)
> +++ src/core/ngx_parse.c	(.../trunk/nginx)	(revision 15961)
> @@ -115,7 +115,7 @@ ngx_parse_time(ngx_str_t *line, ngx_uint_t sec)
>      value = 0;
>      total = 0;
>      step = sec ? st_start : st_month;
> -    scale = sec ? 1 : 1000;
> +    scale = sec ? 1000 : 1;
> 
>      p = line->data;
>      last = p + line->len;


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list