Chinaunix首页 | 论坛 | 博客
  • 博客访问: 94476
  • 博文数量: 25
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 316
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-02 00:39
文章分类

全部博文(25)

文章存档

2013年(25)

我的朋友

分类: PHP

2013-04-22 15:54:41

httpd cpu 100%

解决:lsof -p cpu高的httpd进程的pid,查看cwd(current working directory),
        more /dev/shm/session_.. 查看当前问题httpd的php变量
        strace -p pid -c 查看system call和user call的比例,如果system call的比例很高,很可能出现死循环

        定位到问题php程序目录(/yd/nbsw/news/),检查php和js代码,发现问题如下

在function.php中的function sccl($content)

function sccl($content)
{
    while (((stripos($content,'


')!==false)?true:false)||((stripos($content,'


')!==false)?true:false)||((stripos($content,'


')!==false)?true:false))
    {
        if(function_exists(str_ireplace))                                          //当前php为版本5,所以引入了str_ireplace
        {
            $content=str_ireplace('


','

',$content);      //if中并不存在关于'


'的replace,导致可能出现死循环,建议增加'


'的str_ireplace
            $content=str_ireplace('


','

',$content);
            $content=str_ireplace('


','

',$content);
        }else
        {
            $content=str_replace('


','

',$content);
            $content=str_replace('


','

',$content);
            $content=str_replace('


','

',$content);
            $content=str_replace('


','

',$content);
            $content=str_replace('


','

',$content);
            $content=str_replace('


','

',$content);       
        }
       
    }
    return preg_replace("/

}

location.php中的function getLocation()

function getLocation()
{
    global $conn_ro,$location_cat_id;
    $sql='select name,link,parent_id,depth from cat where cat_id=:cat_id';
    $stat=$conn_ro->prepare($sql);
    $stat->bindParam(":cat_id",$location_cat_id);
    $stat->execute();
    $temp=$stat->fetch();
    $cat_id=$location_cat_id;
    $parent_id=$temp['parent_id'];
    $location=array();
    $location[]=array('cat_id'=>$cat_id,'name'=>$temp['name'],'link'=>$temp['link'],'depth'=>$temp['depth']);
    while($parent_id!=0)
    {
        $sql="select cat_id,name,parent_id,link,depth from cat where cat_id=$parent_id";      //代码本身没问题,建议检查表数据是否存在parent_id为0的数据,或者default value就是0
        $stat=$conn_ro->query($sql);
        $temp=$stat->fetch();
        $parent_id=$temp['parent_id'];
        $location[]=array('cat_id'=>$temp['cat_id'],'name'=>$temp['name'],'link'=>$temp['link'],'depth'=>$temp['depth']);
    }
    return $location;
}

阅读(627) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~