Re: shmop errors
| From: | Ilia A. | Date: | Thu, 17 Jan 2002 20:17:34 +0000 |
| Subject: | Re: shmop errors | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-77367@lists.php.net to get a copy of this message | ||
You have the same script try open the shm segment 2 times, which is WRONG.
Here is a proper example of what you should be doing:
<?php
define("SHMKEY", 0xDEAD);
define("SEMKEY", 0xCAFE);
if( !($shm_id = shmop_open(SHMKEY, 'c', 0644,10)) ) {
exit("Segment already exists and you do not have write permissions to it,
or you cannot create a new segment\n");
}
$data = shmop_read($shm_id, 0, shmop_size($shm_id));
shmop_close($shm_id);
echo $data."\n";
?>
I've also committed the patch to CVS that should eliminate the warning
message. I wonder why Zend required strings with defined length to be null
terminated, sounds like a recipe for disaster, if the length is known it
should be used. But, whatever, please try the latest CVS.
Regards,
Ilia
On January 17, 2002 02:33 am, you wrote:
> On Wed, 2002-01-16 at 21:19, Ilia A. wrote:
> > I've tested your code on 4.1.1 release with the recent SHMOP patch that
> > is already part of the latest CVS. The code worked fine and did not
> > generate any warning or errors.
> >
> > I did however commented out the sem_* functions.
>
> That's funny, I've just downloaded php from cvs today (08.00 CET) and
> this script:
>
> <?php
> define("SHMKEY", 0xDEAD);
> define("SEMKEY", 0xCAFE);
>
> $shm_id = @shmop_open(SHMKEY, "a", 0644, 10);
> if (!$shm_id)
> {
> $shm_id = shmop_open(SHMKEY, "c", 0644, 10);
> shmop_write($shm_id, "0", 0);
> }
>
> $shm_id = shmop_open(SHMKEY, "a", 0644, 10);
>
> $count = shmop_read($shm_id, 0, shmop_size($shm_id));
> shmop_close($shm_id);
> echo $count ."\n";
> ?>
>
> generates the following error:
> Unknown(0) : Warning - String is not zero-terminated (0) (source:
> zend_execute_API.c:274)
>
> Using:
> './configure' \
> '--enable-debug' \
> '--enable-shmop' \
> '--enable-sysvsem' \
> "$@"
>
>
> -- robin