Forum: NGINX ngx_parse_time not handling seconds flag properly?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mike S. (Guest)
on 2009-01-28 05:40
(Received via mailing list)
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;
Igor S. (Guest)
on 2009-01-28 08:58
(Received via mailing list)
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.
This topic is locked and can not be replied to.