After updating php, pcntl_fork calls "errno = 32 Broken pipe"

I recently upgraded from php 5.4.26 to 5.4.28 after the upgrade. I get this error.

Notice: Unknown: send of 6 bytes failed with errno=32 Broken pipe in Unknown on line 0

When I run the following code:

<?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;
}

If I only plug one child, then I do not receive a PHP notification. If I run more than one child, I get a PHP notification for every child except the first.

Are there any clues as to what is going on here?

I assume that he is trying to close the Redis connection several times, but this is code that I have been running for at least 4 months without any problems.

It is just starting to display these notifications after upgrading to 5.4.28.

I looked at the PHP change logs, but I don't see anything that, in my opinion, can explain this problem.

PHP ?

UPDATE:

, Redis, phpredis mysql loading 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();
+4
1

, Redis . , . mysql , .

" MySQL", Redis.

, MySQL Redis . , singleletone, MySQL/Redis reset ( ).

0

Source: https://habr.com/ru/post/1540976/


All Articles