多进程请求https SSL 和 pcntl_fork

1.多进程:

for ($i = 0; $i < 2; ++$i ) {
    $nPID = pcntl_fork(); // 创建子进程
    if ($nPID == 0) {
        // 子进程过程
        //**********************//     
        exit(0); // 执行完后退出
    }
}
$n = 0;
//父进程等待回收子进程,避免僵尸进程
while ($n < 2) {
    $nStatus = -1;
    $nPID = pcntl_wait($nStatus, WNOHANG);
    if ($nPID > 0) {
        echo "{$nPID}  exit\n";
        ++$n;
    }
}

如果多进程请求https链接时,返回false或者ssl connect error

因为https在进行进程之前父进程请求https并进行nss验证,子进程再次验证会因为密钥不同而验证失败

解决办法:

父进程请求放入子进程当中。

参考:https://blog.csdn.net/duandianr/article/details/78568716

猜你喜欢

转载自blog.csdn.net/lzh2018/article/details/82495194