ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#44955 [Opn->Asn]: socket array keys not working as expected
by jani other posts by this author
May 9 2008 9:27AM messages near this date
#44955 [Asn->Opn]: socket array keys not working as expected | #44954 [NEW]: file_get_contents crashes Apache
ID:               44955
 Updated by:       jani@[...].net
 Reported By:      fidojones at fidojones dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Sockets related
 Operating System: Linux
 PHP Version:      5.2.6
-Assigned To:      
+Assigned To:      felipe
 New Comment:

Assigned to Felipe who broke this.


Previous Comments:
------------------------------------------------------------------------

[2008-05-09 14:58:09] fidojones at fidojones dot com

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 this bug report at http://bugs.php.net/?id=44955&edit=1
Thread:
Fidojones At Fidojones Dot Com
felipe
derick
Fidojones At Fidojones Dot Com
jani
Fidojones At Fidojones Dot Com
felipe
jani

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved