我最近在升级后从 php 5.4.26 升级到 5.4.28 我收到此错误
Notice: Unknown: send of 6 bytes failed with errno=32 Broken pipe in Unknown on line 0
每当我运行以下代码时:
<?php
$tasks = array(
'1' => array(),
'2' => array(),
);
ini_set('display_errors', true);
class RedisClass {
private $redis;
public function __construct()
{
$this->redis = new Redis();
$this->redis->connect('localhost', 6379);
}
}
$redis = new RedisClass();
foreach ($tasks as $index => $task)
{
$pid = pcntl_fork();
// This is a child
if($pid == 0)
{
echo "Running ".$index." child in ". getmypid() ."\n";
break;
}
}
switch($pid)
{
case -1 :
die('could not fork');
break;
case 0:
// do the child code
break;
default:
while (pcntl_waitpid(0, $status) != -1)
{
$status = pcntl_wexitstatus($status);
echo "Child completed with status $status\n";
}
echo "Child Done (says: ". getmypid() .")";
exit;
}
如果我只派生一个孩子,那么我不会收到 PHP 通知。如果我运行超过 1 个孩子,我会收到除第一个孩子之外的每个孩子的 PHP 通知。
有没有人知道这里发生了什么?
我假设它试图多次关闭 Redis 连接,但这是我已经运行了至少 4 个月没有任何问题的代码。
仅在升级到 5.4.28 后才开始显示这些通知。
我查看了 PHP 更改日志,但看不到任何我认为可以解释此问题的内容。
我应该将此作为错误报告给 PHP 吗?
更新:
看起来它“可能”是一个 Redis 问题,我正在使用phpredis我用 mysql 连接测试了相同的代码,而不是加载 Redis,但我没有收到错误。
class MysqlClass {
private $mysqli;
public function __construct()
{
$this->mysqli = mysqli_init(); //This is not the droid you are looking for
$this->mysqli->real_connect('IP_ADDRESS',
'USER_NAME',
'PASSWORD');
}
}
$mysql = new MysqlClass();