Ngx_parse_time not handling seconds flag properly?


#1

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.

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;


#2

On Tue, Jan 27, 2009 at 07:29:58PM -0800, Mike S. 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.