用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1144|回复: 0
收起左侧

[HELP] CI框架阻塞在了打印日志

[复制链接]
发表于 2015-10-29 15:57:13 | 显示全部楼层 |阅读模式
我们项目使用了CI框架,今天突然出现不能访问的情况,分析后发现所有的php都阻塞在了打印日志的地方。我们没有改写CI框架的打印日志的地方,请问那位大侠碰见过CI框架会导致日志打印阻塞。

                // Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
                if (strpos($this->_date_fmt, 'u') !== FALSE)
                {
                        $microtime_full = microtime(TRUE);
                        $microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
                        $date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
                        $date = $date->format($this->_date_fmt);
                }
                else
                {
                        $date = date($this->_date_fmt);
                }

                $message .= $level.' - '.$date.' --> '.$msg."\n";

                flock($fp, LOCK_EX);

                for ($written = 0, $length = strlen($message); $written < $length; $written += $result)
                {
                        if (($result = fwrite($fp, substr($message, $written))) === FALSE)
                        {
                                break;
                        }
                }

                flock($fp, LOCK_UN);
                fclose($fp);


红色的代码行是阻塞的位置。

本版积分规则