timeouts break when time changes
|Reported by:||Kristof Provost||Owned by:||somebody|
|uname -a:||Linux oslo 2.6.37-hg39c364f31fe7 #38 Thu Jul 26 11:49:33 CEST 2012 armv7l GNU/Linux|
nginx: nginx version: nginx/1.0.5
nginx: built by gcc 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
nginx: TLS SNI support enabled
nginx: configure arguments: --without-http_rewrite_module --with-http_ssl_module --with-http_sub_module
nginx uses gettimeofday() to obtain the current time for use with timers.
That's wrong, because gettimeofday() doesn't supply monotonic time. It should be using clock_gettime(CLOCK_MONOTONIC) instead.
For example, on one device nginx is a front for php fastgci. Timeouts are configured (fastcgi_send_timeout 300;). One PHP page allows the user to change the system time.
If the time is changed backwards everything's OK, if it's changed forwards nginx returns '504 Gateway timeout'.
The problem was detected on 1.0.5, but from a quick look at the source it is still present.
I'll try to attach a rough patch (working on Linux, but not suitable for inclusion as-is).