|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-10-05 19:31 UTC] FaVo at FaVo dot li
I was working with shared memory segments on PHP 4.0.2, it works fine.
But sometimes (ca. 5% of the calls) it wont put my array into the memory, after a second try sometimes third try with a timeout of 1ms it worked.
Example Code:
while (!$check_mem) {
shm_remove($shm_id);
$uid = shm_attach($shm_id, $global[ARRAY_SIZE]);
$tstamp = time();
$user_data = array (
"nick" => $cur_identity->username,
"channel" => $channel,
"input" => "",
"query" => "",
"query_stat" => "",
"cybernode" => $cur_identity->cybernode_key,
"timestamp" => $tstamp,
"color" => 2,
"channel_info" => 1,
"voice" => 1,
"level" => $user_level
);
$check_mem = shm_put_var($uid, $shm_id, $user_data);
if (!$check_mem) echo "*";
usleep(1);
}
I needed the while-loop and usleep to check if it was successfull.
When i removed the usleep i had about 80 stars (*) sometimes, but worked after that many tries. With the usleep it just needs 2 sometimes 3 tries.
But its only at about 5% of the calls (tried this one with about 700 script calls after i saw it).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 13:00:01 2025 UTC |
On PHP 4.0.3pl1 it seems to be fixed, but i had other problems like that. BD> snapshot? Can you give more info on where it fails (IDs, BD> sizes, errors, etc.)? - the ID's were random int. (the strange thing was that it worked without changing the ID after some tries) - just gave me the same error like when i were trying to create more segments than allowed on the system - the requested size was about 10.000 bytes The other problem with shared memory (shm_get_var): I was reading the Array in a segment in a loop and on every action a user has made. The strange thing was, it was sometimes empty so that i needed to save some information local and restore it. I saw this after some 100 requests, there was no special number .. looked like it lost it randomly -- but for sure it happened when i readed, modified and saved it after a random number of changes (input of the user). The application we were working on has these steps: a) never ending loop for output - reading the shared memory every few ms b) input of the user - reading and modify of the segment if needed c) status - reading the segment every 20 seconds d) a third process - reading the data every minute These was the last problem after i started to write a small script that does that communication via socket with a never-ending-script. Its very slow on PHP, but going to do the same on perl now :/. If you need more detailed information for this problem, i could take a look at the old sources.