#18775 [NEW]: Conflict with variables between father and child
| From: | bariou at brasnah dot com | Date: | Wed, 07 Aug 2002 09:40:03 +0000 |
| Subject: | #18775 [NEW]: Conflict with variables between father and child | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16133@lists.php.net to get a copy of this message | ||
From: bariou@brasnah.com
Operating system: Linux
PHP version: 4.2.2
PHP Bug Type: POSIX related
Bug description: Conflict with variables between father and child
I work with the pcntl extension and sockets, and I'm working on the
developpement of a multiuser server. Several clients can connect limited
to FD_SIZE. I start by a setup :
//Setup of the sockets
....
//Setup of the client array
$i=0;
while($i<FD_SETSIZE){
$client[$i]=null;
$i++;
}
while(1){
Here the parent cheks connection
$new_socket=socket_accept(main_socket);
It accepts and puts the new socket ressource in the first free slot of
the array client
....
$client[$k]=$new_socket
.....
if(!pcntl_fork){
Child here.....
Manage the dialog its OK ! with several connection
....
but when I shutdown a connection, exit is correct
... I need to remove the linked ressources from
$client[$slot] and it is the same for the select
array...
So I do $client[$slot]=null;
.... But It seems to fail, and each time the parent
continues to see the allocate ressources, so it
refuses more connexion, because $client[$slot] is
not change from the parent point of view.
}//En child
}//
Where I'm wrong, is there a bug for variables between parent and child ?
Or maybe I make a confusion for the way
to remove ressources from my client array (value or references) ?
So, now I'm lost, Could somebody gives me some help about please ? I can
send all the code if necessary !
Thanks for your help
Marcel
--
Edit bug report at http://bugs.php.net/?id=18775&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18775&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18775&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18775&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18775&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18775&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18775&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18775&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18775&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18775&r=globals