-
-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Labels
Description
When using fd and resource there is a chance to get the same $key in the ExtEventLoop::addReadStream() method and similar methods, which leads to serious problems reading, writing and responding to events of another connection.
Small example
$fp1 = fsockopen("php.net", 80, $errno, $errstr, 30);
$fp2 = fsockopen("php.net", 80, $errno, $errstr, 30);
// [fp1] Resource id: 4, fd: 3
printf("[fp1] Resource id: %d, fd: %d\n", (int)$fp1, EventUtil::getSocketFd($fp1));
// [fp2] Resource id: 5, fd: 4
printf("[fp2] Resource id: %d, fd: %d\n", (int)$fp2, EventUtil::getSocketFd($fp2));
// bool(true)
var_dump((int)$fp1 === (int)EventUtil::getSocketFd($fp2));
This example demonstrates that we get the same $key when using the $fp1 resource and the file descriptor from $fp2, despite the fact that these are different connections.