[转] thttpd服务器在时间修改后导致CPU占用率过高的问题
2016-11-08 11:57
741 查看
转自:http://blog.csdn.net/taixinlfx/article/details/8727595
httpd挺好用的WEB服务器
可是遇到一个问题,当时间修改后,比如从1970年改到2013年时,thttpd就会占用CPU非常高。
查找后发现,其timers.c中tmr_run函数的实现有些问题,按如下修改后,问题解决:
[cpp] view
plain copy
void
tmr_run( struct timeval* nowP )
{
int h;
Timer* t;
Timer* next;
for ( h = 0; h < HASH_SIZE; ++h )
for ( t = timers[h]; t != (Timer*) 0; t = next )
{
next = t->next;
/* 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 ) )
break;
(t->timer_proc)( t->client_data, nowP );
if ( t->periodic )
{
/* Reschedule. */
t->time.tv_sec += t->msecs / 1000L;
t->time.tv_usec += ( t->msecs % 1000L ) * 1000L;
if ( t->time.tv_usec >= 1000000L )
{
t->time.tv_sec += t->time.tv_usec / 1000000L;
t->time.tv_usec %= 1000000L;
}
//这里是添加的代码
if (t->time.tv_sec + 10*60 < nowP->tv_sec)
t->time.tv_sec = nowP->tv_sec;
//上面是添加的代码
l_resort( t );
}
else
tmr_cancel( t );
}
}
这其中,10*60是为了避免,作者可能确实希望程序能够在追赶当前时间的时候多运行几遍
httpd挺好用的WEB服务器
可是遇到一个问题,当时间修改后,比如从1970年改到2013年时,thttpd就会占用CPU非常高。
查找后发现,其timers.c中tmr_run函数的实现有些问题,按如下修改后,问题解决:
[cpp] view
plain copy
void
tmr_run( struct timeval* nowP )
{
int h;
Timer* t;
Timer* next;
for ( h = 0; h < HASH_SIZE; ++h )
for ( t = timers[h]; t != (Timer*) 0; t = next )
{
next = t->next;
/* 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 ) )
break;
(t->timer_proc)( t->client_data, nowP );
if ( t->periodic )
{
/* Reschedule. */
t->time.tv_sec += t->msecs / 1000L;
t->time.tv_usec += ( t->msecs % 1000L ) * 1000L;
if ( t->time.tv_usec >= 1000000L )
{
t->time.tv_sec += t->time.tv_usec / 1000000L;
t->time.tv_usec %= 1000000L;
}
//这里是添加的代码
if (t->time.tv_sec + 10*60 < nowP->tv_sec)
t->time.tv_sec = nowP->tv_sec;
//上面是添加的代码
l_resort( t );
}
else
tmr_cancel( t );
}
}
这其中,10*60是为了避免,作者可能确实希望程序能够在追赶当前时间的时候多运行几遍
相关文章推荐
- thttpd服务器在时间修改后导致CPU占用率过高的问题
- 记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
- 记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
- 记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
- 记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
- 修复windows环境zookeeper服务器重启有可能会导致客户端CPU占用率100%的问题
- 由于游标打开数过多导致的CPU占用率过高的问题
- Cygwin1.dll版本不正确导致cpu占用率过高问题解决
- Oracle DB 服务器 系统时间修改问题 与 SCN 关系的深入研究
- Oracle DB 服务器 系统时间修改问题 与 SCN 关系的深入研究
- WINDOWS 2008的trustedinstallerexe占用过多CPU导致服务器性能下降的问题处理
- 修改本地系统时间导致的一系列问题
- JAVA中hashmap.get()导致CPU占用过高问题
- 解决cpu占用率过高的问题
- Websphere集群环境下因修改时间而导致的节点停止,节点同步失败问题解决
- 64位系统上运行WMware虚拟机导致CPU利用率过高的问题解决
- 解决计算机名修改或作业移植导致的服务器名问题.sql
- Oracle DB 服务器 系统时间修改问题 与 SCN 关系的深入研究
- Oracle DB 服务器 系统时间修改问题 与 SCN 关系的深入研究