Bug #66884 [NEW]: php://fd/x file descriptors not usable outside CLI mode
| From: | dfuhry at gmail dot com | Date: | Tue, 11 Mar 2014 15:55:57 +0000 |
| Subject: | Bug #66884 [NEW]: php://fd/x file descriptors not usable outside CLI mode | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184725@lists.php.net to get a copy of this message | ||
From: dfuhry at gmail dot com
Operating system: Linux 2.6.32-5-amd64
PHP version: 5.6.0alpha3
Package: Streams related
Bug Type: Bug
Bug description:php://fd/x file descriptors not usable outside CLI mode
Description:
------------
Commit df2a38e7f8603f51afa4c2257b3369067817d818 removed the ability to
use php://fd/x file descriptors in non-CLI mode. Thus, sometime after
PHP 5.3 it became no longer possible to issue parallel async database
queries and stream_select on the array of database connection socket
file descriptors.
When trying to fopen("php://fd/x") (for some file descriptor number "x")
the unhelpful error I receive is: "failed to open stream: operation
failed".
Neither the commit nor source comments make clear to me why the change
was made, but if it is possible to revert it, or otherwise make
alterations to allow the above use case, I would advocate doing so.
I use unexposed pg_socket() method in the below, which returns the file
descriptor of the socket of the database connection.
Test script:
---------------
$conn1 = pg_connect("dbname=a user=b host=c");
$conn2 = pg_connect("dbname=a user=b host=c");
// Next two lines should return resources representing file descriptors
// but instead error and return FALSE.
$r1 = fopen("php://fd/" . pg_socket($conn1));
$r2 = fopen("php://fd/" . pg_socket($conn2));
pg_send_query($conn1, "SELECT pg_sleep(random())");
pg_send_query($conn2, "SELECT pg_sleep(random())");
$r = array($r1, r2);
$w = array();
$e = array();
stream_select($r, $w, $e, NULL); // Would return whichever conn
finished first.
Expected result:
----------------
fopen("php://fd/x") calls return a valid stream resource, not FALSE.
Actual result:
--------------
... failed to open stream: operation failed ...
... failed to open stream: operation failed ...
--
Edit bug report at https://bugs.php.net/bug.php?id=66884&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66884&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66884&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66884&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66884&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66884&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66884&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66884&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66884&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66884&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66884&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66884&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66884&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66884&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66884&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66884&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66884&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66884&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66884&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66884&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66884&r=mysqlcfg