From: b dot mourgues at newtech dot fr Operating system: linux PHP version: 4CVS-2004-07-02 (stable) PHP Bug Type: Sockets related Bug description: fsockopen(unix_socket) and file descriptors leaking
Description: ------------ When using fsockopen with non "available" unix socket, fsockopen returns FALSE (no file descriptor), but an unix socket remains opened in webserver process running php. run watch -n 1 'lsof -U | grep ^apache | wc -l' while opening the following page (replacing "apache" by the real name of your webserver). Suggestion : in file main/network.c, in function _php_stream_sock_open_unix, when php_connect_nonb fails, closesocket(socketd) should be invoked before returning NULL. Reproduce code: --------------- <?php $PHPfd = fsockopen("/dev/null", 0, $PHPerrno, $PHPerrstr); if($PHPfd) { fclose($PHPfd); } ?> <html><head><title>fsockopen</title></head> <body> <pre> PID : <?php print getmypid() . " ". $PHPerrstr . "."; ?> </pre> </body></html> Expected result: ---------------- When fsockopen returns FALSE, no file descriptor created by this function should remain opened -- Edit bug report at http://bugs.php.net/?id=28996&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28996&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28996&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28996&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28996&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28996&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28996&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28996&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28996&r=support Expected behavior: http://bugs.php.net/fix.php?id=28996&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28996&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28996&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28996&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28996&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28996&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28996&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28996&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28996&r=float