转自:http://blog.csdn.net/taixinlfx/article/details/11143713
继,修改时间比原时间晚很多时(比如从1970改到2013),CPU占用率疯狂高的问题之后,
又一个新问题
当修改时间比原时间早时,比如从12点改到11点。此时,thttpd的timer会以12点为基准运行,而实际时间已变成11点。
也就是说,直到1小时之后,众多timer才能得以执行。
这样,必然会带来问题的。
尤其,watchdog_flag如果6分钟不喂狗,就会使程序退出。
悲剧由此发生。。。
修改方式记录如下,
- /* Since the lists are sorted, as soon as we find a timer
- ** that isn't ready yet, we can go on to the next list.
- */
- if ( t->time.tv_sec > nowP->tv_sec ||
- ( t->time.tv_sec == nowP->tv_sec &&
- t->time.tv_usec > nowP->tv_usec ) )
- {
- // begin
- int msec = t->msecs / 1000L;
- if (t->time.tv_sec > nowP->tv_sec + msec)
- {
- //system ("echo \"maybe time changed ....\">> /tmp/thttpd.log");
- t->time.tv_sec = nowP->tv_sec + t->msecs / 1000L;
- t->time.tv_usec = nowP->tv_usec + ( t->msecs % 1000L ) * 1000L;
- }
- // end
- break;
- }