Setting clock backwards may lead to the unexpected thttpd termination. Reproducible: Always Steps to Reproduce: 1) start thttpd daemon (start-up options don't matter); 2) set the system clock 10 minutes back; 3) do nothing for about 6 minutes; 4) thttpd will terminate without a log message. The bug appears in early program versions as well: http://www.mail-archive.com/php-general@lists.php.net/msg174036.html Actual Results: The web-server daemon terminates. Expected Results: The web-server should keep working stable. Reasons. The software utilizes system time to implement a number of internal timers for: - internal watchdog; - periodic file mmap cache expiration check; - periodic idle connections closing; - periodic average rate updates for throttles; - periodic statistics displaying; - connections "wake-up" (recovery); - lingering connections closing; - CGI execution time limit implementation (CGI_TIMELIMIT). So the problem is a scheduled time is no longer valid after system time changing. For example, current time is 15:00 and thttpd schedules some timer to expire in 5 minutes i.e. at 15:05, then system time changes (DST, manual adjusting by user / NTP cron script). As a result, one of the following happens: 1) all active timers expire too late, if system time went backwards; 2) all active timers expire too early (even immediately), if system time went forward. In the first case, if a watchdog handler is not called within appropriate period, the program calls abort() (thttpd.c:handle_alrm()) to go out of hang state (as it's supposed to happen). Other negative consequences (normal operation interruption) are also possible.
Created attachment 238121 [details, diff] Patch to use monotonic time The patch attached checks for MONOTONIC clock availability and uses it for timers expiration evaluation instead of system time. This includes both compile-time check (for the clock access function availability) and run-time check (to ensure that monotonic clock time is fetchable). Is friendly to cross-compiling. Notes: an ideal solution should completely re-write thttpd to POSIX timers.
sorry, but thttpd is really not maintained in gentoo - and hasnt been in a long time. i have proposed it for removal. see bug 331747 thanks
fixed in -r8.
(In reply to comment #3) > fixed in -r8. Hi, I am also facing the same issue. I have applied your patch but problem is still exists. Can you send me the link to download -r8 version of thttpd2.25b Thanks and Regards, Nishant Joshi