From: fidojones at fidojones dot com Operating system: Linux PHP version: 5.2.6 PHP Bug Type: Sockets related Bug description: socket array keys not working as expected
Description: ------------ This bugfixed http://bugs.php.net/bug.php?id=44197 make work socket arrays some strange. I think that some HASH_KEY is not contemplate in switch case line 605 switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(sock_array), &key, &key_len, &num_key, 0, NULL)) { Nanoweb server http://nanoweb.si.kz/, when try to access it, eat cpu at 99% time with this socket patch. Reproduce code: --------------- <?php $ary = array(); $strone = 'Message From Parent.'; $strtwo = 'Message From Child.'; if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $ary) === false) { echo "socket_create_pair() failed. Reason: ".socket_strerror(socket_last_error()); } $pid = pcntl_fork(); if ($pid == -1) { echo 'Could not fork Process.'; } elseif ($pid) { /*parent*/ socket_close($ary[0]); if (socket_write($ary[1], $strone, strlen($strone)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[1])); } if (socket_read($ary[1], strlen($strtwo), PHP_BINARY_READ) == $strtwo) { echo "Recieved $strtwo\n"; } socket_close($ary[1]); } else { /*child*/ socket_close($ary[1]); if (socket_write($ary[0], $strtwo, strlen($strtwo)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[0])); } if (socket_read($ary[0], strlen($strone), PHP_BINARY_READ) == $strone) { echo "Recieved $strone\n"; } socket_close($ary[0]); } ?> Expected result: ---------------- php 5.2.5 result: bash$ php socket.php Recieved Message From Child. Recieved Message From Parent. Actual result: -------------- php 5.2.6 result: bash# php socket.php Recieved Message From Child. bash# Recieved Message From Parent. An here wait and you should hit return to see the bash prompt again -- Edit bug report at http://bugs.php.net/?id=44955&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44955&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44955&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44955&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44955&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44955&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44955&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44955&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44955&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44955&r=support Expected behavior: http://bugs.php.net/fix.php?id=44955&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44955&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44955&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44955&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44955&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44955&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44955&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44955&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44955&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44955&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44955&r=mysqlcfg