[PHP] Example PHP shared memory code

2009-05-23 Thread Richard W
Hi

I was wondering if anyone has some sample code whereby the PHP script
connects to and reads data from some shared memory in Linux, where the
shared memory was originally created by a* linux thread (as opposed to some
PHP script)*? The example code needs to use shmop_open(...).

Thanks in advance.

Cheers,
Richard


Re: [PHP] Shared memory - linx and PHP newbie

2009-05-22 Thread Richard W
Thanks Daniel for your suggestions.

What I have found are:
1) I'm assuming the key is good. A value of 1947143245 is returned.

2) I have set the permission of the shared memory ("program.SCShared") to
777 octal (full read/write/execute access). The group and owner of the file
is my login ('eclipse'). According to the PHP manual for shmop_open(..), I
do not need to set the 'mode' parameter of this function (eg, to 0777)
because I'm trying to connect to an existing shared memory block. Despite
this, I've tried  setting mode=0777, but errors were generated when I ran
the code. I event tried changing the user and group to 'www-data' with no
luck.

3) I added the debug_backtrace and the display result was "array(0) {}"
inserted where debug_backtrace() was added as shown, but I'm not sure what
the result really means:

CODE

";
}

$shm_id = shmop_open ($shm_key,"w",0,0);

if ($shm_id == FALSE)
{
echo "\n Shared memory doesnt exists ";
}
else
{
echo "\n Shared memory exists ";
}

$shm_size = shmop_size ($shm_id);

var_dump(debug_backtrace());

echo "\n the size of shared memory is $shm_size ";

$shm_data = shmop_read($shm_id, 0, 32);

if ($shm_data == FALSE)
{
echo "\nCould not read data. : $php_errormsg ";
}
else
{
echo "\nRead successful ";
}

echo "\n read1 is $shm_data ";

$shm_data = unserialize($shm_data);

echo "\n read2 is $shm_data ";

$i = strpos($shm_data, "\0");

if ($i === FALSE)
{
echo "\n String is NULL ";
}
else
{
$result = substr($shm_data, 0, $i);

print_r($result);

echo "";
}

shmop_close($shm_id);

echo "\nDetached from shared memory";

?>

=

===RESULT OF CODE
array(0) { } Shared memory exists
array(0) { } the size of shared memory is 1
Read successful
read1 is PHP_SM�&'
read2 is
String is NULL
Detached from shared memory
=

4) The data I expecting to read is "9876.54321" because this is the first
string in memory. A 'cat' of the shared memory is shown:


r...@ts7800:shm# cat program.SCShared
9876.5432101.230034.50678.9010002345.678900

5)  Is there anything else that  can try?

Regards,
Richard.


On Thu, May 21, 2009 at 11:17 PM, Daniel Brown  wrote:

> On Thu, May 21, 2009 at 10:15, Richard W  wrote:
> >
> > Any help will be greatly appreciated, especially answering 2) as to why I
> > can't read the data.
>
>Are you certain that the problem lies within the shmop reading?
> Check to see if the file is actually being accessed properly, the key
> is good from your ftok(), etc.  You may also want to make sure that
> things as basic as permissions and 'who created' vs. 'who can read'
> (since you're trying to run it from the web server) match up
> appropriately.
>
>With just a cursory glance, the shmop_read() piece itself looks
> fine, which suggests to me that there may be other problems.  See if
> the logs spit anything out, or try to debug the things with an `or
> die("Here's the error.\n");` tacked onto the end of the suspected
> lines.  If it's crashing out, consider a cachegrind or
> debug_backtrace() run.
>
>As for the memory being read, I'd agree that it does seem that it
> is, since shm_open() is returning something other than FALSE, but that
> doesn't mean that it's `=== TRUE` either.  It may instead be returning
> a message or another unexpected result that, in empty(), may evaluate
> to TRUE and allow it to echo out the message in your test condition.
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1
>


Re: [PHP] Shared memory - linx and PHP newbie

2009-05-21 Thread Daniel Brown
On Thu, May 21, 2009 at 10:15, Richard W  wrote:
>
> Any help will be greatly appreciated, especially answering 2) as to why I
> can't read the data.

Are you certain that the problem lies within the shmop reading?
Check to see if the file is actually being accessed properly, the key
is good from your ftok(), etc.  You may also want to make sure that
things as basic as permissions and 'who created' vs. 'who can read'
(since you're trying to run it from the web server) match up
appropriately.

With just a cursory glance, the shmop_read() piece itself looks
fine, which suggests to me that there may be other problems.  See if
the logs spit anything out, or try to debug the things with an `or
die("Here's the error.\n");` tacked onto the end of the suspected
lines.  If it's crashing out, consider a cachegrind or
debug_backtrace() run.

As for the memory being read, I'd agree that it does seem that it
is, since shm_open() is returning something other than FALSE, but that
doesn't mean that it's `=== TRUE` either.  It may instead be returning
a message or another unexpected result that, in empty(), may evaluate
to TRUE and allow it to echo out the message in your test condition.

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shared memory - linx and PHP newbie

2009-05-21 Thread Richard W
Hi

I have a query regarding shared memory created under Linux and then
accessing it by PHP script.

For my application, I have created a shared memory block in Debian Linux
using the shm_open(..), ftruncate(...) and mmap(...) function calls.

The shared memory block is of size 6304 bytes long. It is store 197 strings
of 32 characters long. I am confident that the shared memory block is
correctly created because when I go navigate to the /shm directory I
find the shared memory block called "/program.SCShared" present and it is of
size 6304 bytes. In addition to that, I have also written some strings to to
the shared memory, where each string starts at every 32 bytes. I have
verified that I can read these strings back successfully.

What I would like to do now is have some PHP script to read the strings out
of the shared memory so the strings can be displayed on a web page.

>From what I can gather from the PHP web site, it appears that I need to use
the shared memory functions as given in
http://au.php.net/manual/en/ref.shmop.php.

Specifically, since my strings start at 32-byte boundaries, the function:


string *shmop_read* ( int $shmid , int $start , int $count);

seems to be the ideal read routine to use. For example, if I want to read
the third string, I believe i write:


$shm_data = shmop_read($shmid, 64, 32);


Below is my code:

==




==

Running this script shows, it appears that I'm connecting to my shared
memory "/dev/shm/program.SCShared" because "Shared memory exists" is
displayed.

However, I get the following which I would like some help with:

1) The size of the memory block is returning 1 and not 6304 bytes as
expected. I believe 1 is the default size if the memory block is created
from scratch using *shm_attach. Does the same apply to shmop_open. If so,
why is it being created?*

2) The call $shm_data = shmop_read($shm_id, 0, 32), which reads the first
string, returns no result. Does any know why this is the case when I know
that there is a string there because I have added it there using some C
code.

3) Is there another way I can access these strings without using the
shmop_ routines? I have tried using shm_attach(...), shm_get_var(...),
but this seems to be too hard because it requires variable keys. Should I be
using MySQL?

Any help will be greatly appreciated, especially answering 2) as to why I
can't read the data.

Regards,
Richard.


Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Per Jessen
Kent Larsson wrote:

> In absence of shared memory and threads. What I really must have is
> some kind of mutex functionality. I will be manipulating files on disk
> and I don't want two instances to be able to touch the disk at the
> same time. 

Touch the disk or touch the file?  I assume you meant the latter, i.e.
you don't want two instances to operate on the same file concurrently. 

> Is there something I could use for mutual exclusion? If 
> there aren't any dedicated methods, are there 100% reliable
> workarounds?

Look up file locking.  In fact, this was the topic of a very recent
thread.


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Micah Gersten
http://us2.php.net/apc

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Kent Larsson wrote:
> Hi,
>
> Is it possible to have shared memory in the form of shared global variables
> in PHP? Or any other form of shared memory? And if that is the case, is
> there any form of mutex functionality which may be used to assure
> syncronized access to this memory?
>
> My next question is related to the first one.
>
> Is it possible to have a thread running for processing of information. This
> thread should be accessed from all the session instances, and it would also
> need to be syncronized. I would like to have something like:
> jobProcessorThread.addJob(aJobClassInstance)
>
> The job processor thread should work with the jobs in its queue until the
> queue is empty. Then it should idle until more requests are received.
>
> And my last question.
>
> Is it possible to let any code run and perform its work after PHP has sent
> the page to the user? This could be an alternative to having a worker thread
> in if it's also possible to have mutexes and shared memory. Then the worker
> thread jobs could be processed after a page has been sent inside a critical
> block protected by mutex functionality.
>
> Best regards,
> Kent
>
>   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Eric Butera
On Mon, Sep 1, 2008 at 5:45 PM, Kent Larsson <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thank you for your answer. I was hoping there were a solution. :-/ It would
> have been nice as PHP has a large install base and is a quite common element
> in cheap web hosting solutions. Has anyone else got any more comments or
> suggestions?
>
> In absence of shared memory and threads. What I really must have is some
> kind of mutex functionality. I will be manipulating files on disk and I
> don't want two instances to be able to touch the disk at the same time. Is
> there something I could use for mutual exclusion? If there aren't any
> dedicated methods, are there 100% reliable workarounds?
>
> On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen <[EMAIL PROTECTED]> wrote:
>
>> Kent Larsson wrote:
>>
>> > Hi,
>> >
>> > Is it possible to have shared memory in the form of shared global
>> > variables in PHP? Or any other form of shared memory? And if that is
>> > the case, is there any form of mutex functionality which may be used
>> > to assure syncronized access to this memory?
>> >
>> > My next question is related to the first one.
>>
>> I can't answer any of your questions, but if you need shared memory,
>> mutexes and threading, I would advice against using PHP.
>>
>>
>> /Per Jessen, Zürich
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

Perhaps these may be of interest:

http://us.php.net/manual/en/ref.shmop.php

http://us3.php.net/pcntl_fork

http://us3.php.net/manual/en/book.sem.php


Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Kent Larsson
Hi,

Thank you for your answer. I was hoping there were a solution. :-/ It would
have been nice as PHP has a large install base and is a quite common element
in cheap web hosting solutions. Has anyone else got any more comments or
suggestions?

In absence of shared memory and threads. What I really must have is some
kind of mutex functionality. I will be manipulating files on disk and I
don't want two instances to be able to touch the disk at the same time. Is
there something I could use for mutual exclusion? If there aren't any
dedicated methods, are there 100% reliable workarounds?

On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen <[EMAIL PROTECTED]> wrote:

> Kent Larsson wrote:
>
> > Hi,
> >
> > Is it possible to have shared memory in the form of shared global
> > variables in PHP? Or any other form of shared memory? And if that is
> > the case, is there any form of mutex functionality which may be used
> > to assure syncronized access to this memory?
> >
> > My next question is related to the first one.
>
> I can't answer any of your questions, but if you need shared memory,
> mutexes and threading, I would advice against using PHP.
>
>
> /Per Jessen, Zürich
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Per Jessen
Kent Larsson wrote:

> Hi,
> 
> Is it possible to have shared memory in the form of shared global
> variables in PHP? Or any other form of shared memory? And if that is
> the case, is there any form of mutex functionality which may be used
> to assure syncronized access to this memory?
> 
> My next question is related to the first one.

I can't answer any of your questions, but if you need shared memory,
mutexes and threading, I would advice against using PHP.


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?

2008-09-01 Thread Kent Larsson
Hi,

Is it possible to have shared memory in the form of shared global variables
in PHP? Or any other form of shared memory? And if that is the case, is
there any form of mutex functionality which may be used to assure
syncronized access to this memory?

My next question is related to the first one.

Is it possible to have a thread running for processing of information. This
thread should be accessed from all the session instances, and it would also
need to be syncronized. I would like to have something like:
jobProcessorThread.addJob(aJobClassInstance)

The job processor thread should work with the jobs in its queue until the
queue is empty. Then it should idle until more requests are received.

And my last question.

Is it possible to let any code run and perform its work after PHP has sent
the page to the user? This could be an alternative to having a worker thread
in if it's also possible to have mutexes and shared memory. Then the worker
thread jobs could be processed after a page has been sent inside a critical
block protected by mutex functionality.

Best regards,
Kent


Re: [PHP] shared memory access - shmod_open

2007-12-11 Thread Rolf_

I tried the php function chmod($sem, 0644) which works fine even if it
converts the octal number too, cf. xdebug trace file:

  0.0037  50280 -> chmod('/tmp/1521387531.sem', 420)
...myScripts/test.php:11
   >=> TRUE
  0.0039  50280 -> shmop_open(2013277949, 'c', 420, 1)
...myScripts/test.php:15
   >=> FALSE
 
So I think there must be something else wrong with my shmop_open. I also
tried shmop_open($sem_key, "c", "0644", 1) and shmop_open($sem_key, "c",
420, 1), which doesn´t work either. 

Thank you for your help,
Rolf.







Peter Ford-4 wrote:
> 
> Richard Lynch wrote:
>> On Thu, December 6, 2007 2:44 am, Rolf_ wrote:
>>> I have a problem working with shmop_open() in a Solaris environment.
>>> The
>>> following cli-script works fine, except shmod_open returns a warning
>>> 'unable
>>> to attach or create shared memory segment':
>>>
>>> >> $sem = "/tmp/" . rand() . ".sem";
>>> touch ($sem);
>>> echo "sem $sem \n";
>>>
>>> $sem_key = ftok($sem, 'w');
>>> echo "sem_key $sem_key \n";
>>>
>>> if ($sem_key == -1) { die ("ftok error"); }
>>>
>>> $shm_id = shmop_open($sem_key, "w", 0644, 1);
>>> echo "shm_id $shm_id\n";
>>> ?>
>>>
>>> I checked the $sem_key with the Solaris ipcs command. The file exists
>>> and
>>> the read/write rights are correct. I tried explictly to call
>>> shmop_open with
>>> the right key - the error message remains the same.
>>>
>>> Checking out different access mode like "r" does not succeed too. In
>>> the
>>> Xdebug output, php changes the value 0644 to 420, i.e.
>>> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
>>> --enable-shmop.
>>>
>>> Does anyone has an idea what I might also check?
>> 
>> Perhaps the 0644 needs to be expressed in some other way?
>> 
>> I know it works fine that way for chmod and friends, so I wouldn't
>> expect it, but...
>> 
>> Or maybe 420 *IS* the right value, and you're on a red herring.
>> 
>> Try Googling for the error message and Solaris if you haven't done
>> that yet.
>> 
> 
> The problem is that 0644 == 420, because 0644 is parsed as "644 base 8"
> (the
> zero prefix forces the number to octal...)
> So 420 (decimal) is actually the correct value. RTFM for chmod, which
> gives you
> a big hint about this...
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/shared-memory-access---shmod_open-tp14188465p14278683.html
Sent from the PHP - General mailing list archive at Nabble.com.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory access - shmod_open

2007-12-07 Thread Peter Ford
Richard Lynch wrote:
> On Thu, December 6, 2007 2:44 am, Rolf_ wrote:
>> I have a problem working with shmop_open() in a Solaris environment.
>> The
>> following cli-script works fine, except shmod_open returns a warning
>> 'unable
>> to attach or create shared memory segment':
>>
>> > $sem = "/tmp/" . rand() . ".sem";
>> touch ($sem);
>> echo "sem $sem \n";
>>
>> $sem_key = ftok($sem, 'w');
>> echo "sem_key $sem_key \n";
>>
>> if ($sem_key == -1) { die ("ftok error"); }
>>
>> $shm_id = shmop_open($sem_key, "w", 0644, 1);
>> echo "shm_id $shm_id\n";
>> ?>
>>
>> I checked the $sem_key with the Solaris ipcs command. The file exists
>> and
>> the read/write rights are correct. I tried explictly to call
>> shmop_open with
>> the right key - the error message remains the same.
>>
>> Checking out different access mode like "r" does not succeed too. In
>> the
>> Xdebug output, php changes the value 0644 to 420, i.e.
>> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
>> --enable-shmop.
>>
>> Does anyone has an idea what I might also check?
> 
> Perhaps the 0644 needs to be expressed in some other way?
> 
> I know it works fine that way for chmod and friends, so I wouldn't
> expect it, but...
> 
> Or maybe 420 *IS* the right value, and you're on a red herring.
> 
> Try Googling for the error message and Solaris if you haven't done
> that yet.
> 

The problem is that 0644 == 420, because 0644 is parsed as "644 base 8" (the
zero prefix forces the number to octal...)
So 420 (decimal) is actually the correct value. RTFM for chmod, which gives you
a big hint about this...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory access - shmod_open

2007-12-07 Thread Rolf_

Yes, thank you. I checked this thread before writing here. But following the
hints there does not help either.

Rolf.




Daniel Brown-5 wrote:
> 
> On Dec 6, 2007 3:44 AM, Rolf_ <[EMAIL PROTECTED]> wrote:
>>
>> Dear List,
>>
>> I have a problem working with shmop_open() in a Solaris environment. The
>> following cli-script works fine, except shmod_open returns a warning
>> 'unable
>> to attach or create shared memory segment':
> [snip!]
> 
> Rolf,
> 
> I don't know if it will help you in your exact situation, but
> here's a link to someone who had a similar problem, found in the
> archives:
> http://archives.neohapsis.com/archives/php/2005-11/0028.html
> 
> -- 
> Daniel P. Brown
> [Phone Numbers Go Here!]
> [They're Hidden From View!]
> 
> If at first you don't succeed, stick to what you know best so that you
> can make enough money to pay someone else to do it for you.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/shared-memory-access---shmod_open-tf4954760.html#a14211184
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory access - shmod_open

2007-12-07 Thread Rolf_

Thank you for your reply. 

shmop_open($sem_key, "w", 420, 1) creates the same error message:

---
[07-Dec-2007 12:34:23] PHP Warning:  shmop_open(): unable to attach or
create shared memory segment in ...
[07-Dec-2007 12:34:23] PHP Stack trace:
[07-Dec-2007 12:34:23] PHP   1. {main}() ...test.php:0
[07-Dec-2007 12:34:23] PHP   2. shmop_open(1996497860, 'w', 420, 1) ...
test.php:13


Now PHP (or whatever) doesn't change the value 420. I already googled for
the message, but could not find any hints.

Regards,
Rolf.




Richard Lynch wrote:
> 
> On Thu, December 6, 2007 2:44 am, Rolf_ wrote:
>> I have a problem working with shmop_open() in a Solaris environment.
>> The
>> following cli-script works fine, except shmod_open returns a warning
>> 'unable
>> to attach or create shared memory segment':
>>
>> > $sem = "/tmp/" . rand() . ".sem";
>> touch ($sem);
>> echo "sem $sem \n";
>>
>> $sem_key = ftok($sem, 'w');
>> echo "sem_key $sem_key \n";
>>
>> if ($sem_key == -1) { die ("ftok error"); }
>>
>> $shm_id = shmop_open($sem_key, "w", 0644, 1);
>> echo "shm_id $shm_id\n";
>> ?>
>>
>> I checked the $sem_key with the Solaris ipcs command. The file exists
>> and
>> the read/write rights are correct. I tried explictly to call
>> shmop_open with
>> the right key - the error message remains the same.
>>
>> Checking out different access mode like "r" does not succeed too. In
>> the
>> Xdebug output, php changes the value 0644 to 420, i.e.
>> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
>> --enable-shmop.
>>
>> Does anyone has an idea what I might also check?
> 
> Perhaps the 0644 needs to be expressed in some other way?
> 
> I know it works fine that way for chmod and friends, so I wouldn't
> expect it, but...
> 
> Or maybe 420 *IS* the right value, and you're on a red herring.
> 
> Try Googling for the error message and Solaris if you haven't done
> that yet.
> 
> -- 
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/shared-memory-access---shmod_open-tf4954760.html#a14211151
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory access - shmod_open

2007-12-06 Thread Richard Lynch
On Thu, December 6, 2007 2:44 am, Rolf_ wrote:
> I have a problem working with shmop_open() in a Solaris environment.
> The
> following cli-script works fine, except shmod_open returns a warning
> 'unable
> to attach or create shared memory segment':
>
>  $sem = "/tmp/" . rand() . ".sem";
> touch ($sem);
> echo "sem $sem \n";
>
> $sem_key = ftok($sem, 'w');
> echo "sem_key $sem_key \n";
>
> if ($sem_key == -1) { die ("ftok error"); }
>
> $shm_id = shmop_open($sem_key, "w", 0644, 1);
> echo "shm_id $shm_id\n";
> ?>
>
> I checked the $sem_key with the Solaris ipcs command. The file exists
> and
> the read/write rights are correct. I tried explictly to call
> shmop_open with
> the right key - the error message remains the same.
>
> Checking out different access mode like "r" does not succeed too. In
> the
> Xdebug output, php changes the value 0644 to 420, i.e.
> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
> --enable-shmop.
>
> Does anyone has an idea what I might also check?

Perhaps the 0644 needs to be expressed in some other way?

I know it works fine that way for chmod and friends, so I wouldn't
expect it, but...

Or maybe 420 *IS* the right value, and you're on a red herring.

Try Googling for the error message and Solaris if you haven't done
that yet.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory access - shmod_open

2007-12-06 Thread Daniel Brown
On Dec 6, 2007 3:44 AM, Rolf_ <[EMAIL PROTECTED]> wrote:
>
> Dear List,
>
> I have a problem working with shmop_open() in a Solaris environment. The
> following cli-script works fine, except shmod_open returns a warning 'unable
> to attach or create shared memory segment':
[snip!]

Rolf,

I don't know if it will help you in your exact situation, but
here's a link to someone who had a similar problem, found in the
archives:
http://archives.neohapsis.com/archives/php/2005-11/0028.html

-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] shared memory access - shmod_open

2007-12-06 Thread Rolf_

Dear List,

I have a problem working with shmop_open() in a Solaris environment. The
following cli-script works fine, except shmod_open returns a warning 'unable
to attach or create shared memory segment':



I checked the $sem_key with the Solaris ipcs command. The file exists and
the read/write rights are correct. I tried explictly to call shmop_open with
the right key - the error message remains the same. 

Checking out different access mode like "r" does not succeed too. In the
Xdebug output, php changes the value 0644 to 420, i.e.
shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
--enable-shmop.

Does anyone has an idea what I might also check?

Thanks in advance,
Rolf_
-- 
View this message in context: 
http://www.nabble.com/shared-memory-access---shmod_open-tf4954760.html#a14188465
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory Problem

2005-11-17 Thread Jochem Maas

Yaswanth Narvaneni wrote:

Hi!

I found the solution to my prob. SELinux was enabled in the server
which needs disabling. After disabling SELinux it was working great.
Thanks for your help guys.

Another small query though, is there anyway to enable SELinux and as
well use shared memory between PHP and C++? I know using Zend engine


the zend engine is free.. I think you mean 'Zend ' instead 
:-)


would solve the prob, but we need to buy zend which is very costly for
me, any other solution is welcome.


I have no idea if it either possible or efficient enough for your
needs but you may be able to use pipes?

http://php.net/proc_open




Regards,
Yaswanth

On 11/16/05, Curt Zirzow <[EMAIL PROTECTED]> wrote:


On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:


Hi!

I have a server written in C++ and my webpages are in PHP. The PHP has
to communicate with the server using shared memory. This was working
fine on the server running FC-1 with php-4.3.8. We recently migrated
to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
displays is as follows:

shmop_open(): unable to attach or create shared memory segment in
/var/www/html/sharedmem.php on line 2

The server opens the shm in 666 (originally was 644) even then it was
not working. I can see the shared mem open using 'ipcs' command.

...
$shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
to Access Shared Memory");


You might want to try to open it within the same mode that the
server created it in:

1)
 $shm_id = shmop_open($shm_key, "a",0666,0);

2)
 are you 100% sure the key is valid? the error message you are
 getting seems to point in this direction since the shmop_open is
 failing on the C call to shmget(), wich usually fails when either
 you dont have enough memory to create it (which you arn't doing),
 some other creation problems, or that the key supplied wasn't
 found.


Curt.
--

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi!

I found the solution to my prob. SELinux was enabled in the server
which needs disabling. After disabling SELinux it was working great.
Thanks for your help guys.

Another small query though, is there anyway to enable SELinux and as
well use shared memory between PHP and C++? I know using Zend engine
would solve the prob, but we need to buy zend which is very costly for
me, any other solution is welcome.

Regards,
Yaswanth

On 11/16/05, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
> > Hi!
> >
> > I have a server written in C++ and my webpages are in PHP. The PHP has
> > to communicate with the server using shared memory. This was working
> > fine on the server running FC-1 with php-4.3.8. We recently migrated
> > to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
> > displays is as follows:
> >
> > shmop_open(): unable to attach or create shared memory segment in
> > /var/www/html/sharedmem.php on line 2
> >
> > The server opens the shm in 666 (originally was 644) even then it was
> > not working. I can see the shared mem open using 'ipcs' command.
> >
> > ...
> > $shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
> > to Access Shared Memory");
>
> You might want to try to open it within the same mode that the
> server created it in:
>
> 1)
>   $shm_id = shmop_open($shm_key, "a",0666,0);
>
> 2)
>   are you 100% sure the key is valid? the error message you are
>   getting seems to point in this direction since the shmop_open is
>   failing on the C call to shmget(), wich usually fails when either
>   you dont have enough memory to create it (which you arn't doing),
>   some other creation problems, or that the key supplied wasn't
>   found.
>
>
> Curt.
> --
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi!

There is a strange problem now. This is the error message my php file gives.
"kernel not configured for shared memory kernel not configured for
semaphores kernel not configured for message queues"

The source is as follows:
";
print system("ipcs");

?>

when I logged into my machine as user apache and tried ipcs command it
was working fine (I changed the shell of apache from /sbin/nologin to
/bin/bash)

Any clue??

Regards,
Yaswanth


On 11/16/05, Yaswanth Narvaneni <[EMAIL PROTECTED]> wrote:
> Hi Curt,
>
> These are my open shared memories in the server output of ipcs command.
>
> -- Shared Memory Segments 
> keyshmid  owner  perms  bytes  nattch status
> 0x 18645001   gOLeM 600393216 2  dest
> 0x162e 18808842   root  66630 1
>
> The last one the the sharedmem the php will be using. the key is 5678
> and as you said I
> have modified my code to
>
> $shm_id = shmop_open(intval($shm_key), "a",666,0) or die("FATAL
> ERROR:: $php_errormsg");
>
> U obtain the shm_key from a file. The key I am using is 5678 and it is
> getting that value from the file. I even hardcoded the value, but the
> error is not getting solved.
>
> Is this a proble with any of the server configs? Coz we have
> downloaded an example C file and this is also not working with the
> PHP. Where as if the server and client both written in C are able to
> communicate using the shared memory. Any clue any one??
>
> Ok...just a crazy query...does it have anything to do with
> Notice: import_request_variables(): No prefix specified - possible
> security hazard in
>
> which occurs due to register_globals set to Off??
>
> On 11/16/05, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> > On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
> > > Hi!
> > >
> > > I have a server written in C++ and my webpages are in PHP. The PHP has
> > > to communicate with the server using shared memory. This was working
> > > fine on the server running FC-1 with php-4.3.8. We recently migrated
> > > to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
> > > displays is as follows:
> > >
> > > shmop_open(): unable to attach or create shared memory segment in
> > > /var/www/html/sharedmem.php on line 2
> > >
> > > The server opens the shm in 666 (originally was 644) even then it was
> > > not working. I can see the shared mem open using 'ipcs' command.
> > >
> > > ...
> > > $shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
> > > to Access Shared Memory");
> >
> > You might want to try to open it within the same mode that the
> > server created it in:
> >
> > 1)
> >   $shm_id = shmop_open($shm_key, "a",0666,0);
> >
> > 2)
> >   are you 100% sure the key is valid? the error message you are
> >   getting seems to point in this direction since the shmop_open is
> >   failing on the C call to shmget(), wich usually fails when either
> >   you dont have enough memory to create it (which you arn't doing),
> >   some other creation problems, or that the key supplied wasn't
> >   found.
> >
> >
> > Curt.
> > --
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> "In theory there is no difference between theory and practice.
> In practice there is." -- Fortune Cookie
>


--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory Problem

2005-11-16 Thread Yaswanth Narvaneni
Hi Curt,

These are my open shared memories in the server output of ipcs command.

-- Shared Memory Segments 
keyshmid  owner  perms  bytes  nattch status
0x 18645001   gOLeM 600393216 2  dest
0x162e 18808842   root  66630 1

The last one the the sharedmem the php will be using. the key is 5678
and as you said I
have modified my code to

$shm_id = shmop_open(intval($shm_key), "a",666,0) or die("FATAL
ERROR:: $php_errormsg");

U obtain the shm_key from a file. The key I am using is 5678 and it is
getting that value from the file. I even hardcoded the value, but the
error is not getting solved.

Is this a proble with any of the server configs? Coz we have
downloaded an example C file and this is also not working with the
PHP. Where as if the server and client both written in C are able to
communicate using the shared memory. Any clue any one??

Ok...just a crazy query...does it have anything to do with
Notice: import_request_variables(): No prefix specified - possible
security hazard in

which occurs due to register_globals set to Off??

On 11/16/05, Curt Zirzow <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
> > Hi!
> >
> > I have a server written in C++ and my webpages are in PHP. The PHP has
> > to communicate with the server using shared memory. This was working
> > fine on the server running FC-1 with php-4.3.8. We recently migrated
> > to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
> > displays is as follows:
> >
> > shmop_open(): unable to attach or create shared memory segment in
> > /var/www/html/sharedmem.php on line 2
> >
> > The server opens the shm in 666 (originally was 644) even then it was
> > not working. I can see the shared mem open using 'ipcs' command.
> >
> > ...
> > $shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
> > to Access Shared Memory");
>
> You might want to try to open it within the same mode that the
> server created it in:
>
> 1)
>   $shm_id = shmop_open($shm_key, "a",0666,0);
>
> 2)
>   are you 100% sure the key is valid? the error message you are
>   getting seems to point in this direction since the shmop_open is
>   failing on the C call to shmget(), wich usually fails when either
>   you dont have enough memory to create it (which you arn't doing),
>   some other creation problems, or that the key supplied wasn't
>   found.
>
>
> Curt.
> --
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory Problem

2005-11-15 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 03:33:22AM +0530, Yaswanth Narvaneni wrote:
> Hi!
> 
> I have a server written in C++ and my webpages are in PHP. The PHP has
> to communicate with the server using shared memory. This was working
> fine on the server running FC-1 with php-4.3.8. We recently migrated
> to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
> displays is as follows:
> 
> shmop_open(): unable to attach or create shared memory segment in
> /var/www/html/sharedmem.php on line 2
> 
> The server opens the shm in 666 (originally was 644) even then it was
> not working. I can see the shared mem open using 'ipcs' command.
> 
> ...
> $shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
> to Access Shared Memory");

You might want to try to open it within the same mode that the
server created it in:

1)
  $shm_id = shmop_open($shm_key, "a",0666,0);

2)
  are you 100% sure the key is valid? the error message you are
  getting seems to point in this direction since the shmop_open is
  failing on the C call to shmget(), wich usually fails when either
  you dont have enough memory to create it (which you arn't doing),
  some other creation problems, or that the key supplied wasn't
  found.


Curt.
--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shared Memory Problem

2005-11-15 Thread Yaswanth Narvaneni
Hi!

I have a server written in C++ and my webpages are in PHP. The PHP has
to communicate with the server using shared memory. This was working
fine on the server running FC-1 with php-4.3.8. We recently migrated
to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it
displays is as follows:

shmop_open(): unable to attach or create shared memory segment in
/var/www/html/sharedmem.php on line 2

The server opens the shm in 666 (originally was 644) even then it was
not working. I can see the shared mem open using 'ipcs' command.

The source code of PHP is as follows:
"; // These are fine

# print $shm_key;

$shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable
to Access Shared Memory");

/*$shm_size = shmop_size($shm_id);
DEBUG:: print ("Shared Memory Block Size: " . $shm_size."\n");
*/
// Now lets read the string back
$data = shmop_read($shm_id, 0, $shm_size);
if (!$data) {
echo "FATAL ERROR:: Couldn't read from shared memory\n";
exit;
}
?>

The PHPInfo of the servers are as follows (if it will help):

- Server where its working fine -
-- Start --

'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux'
'--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr'
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--cache-file=../config.cache'
'--with-config-file-path=/etc'
'--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect'
'--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-db4=/usr'
'--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr'
'--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf'
'--without-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp'
'--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png'
'--with-pspell' '--with-regex=system' '--with-xml'
'--with-expat-dir=/usr' '--with-dom=shared,/usr'
'--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-xmlrpc=shared'
'--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU'
'--enable-bcmath' '--enable-exif' '--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path'
'--enable-track-vars' '--enable-trans-sid' '--enable-yp'
'--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos'
'--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared'
'--with-snmp=shared,/usr' '--with-snmp=shared'
'--enable-ucd-snmp-hack' '--with-unixODBC=shared'
'--enable-memory-limit' '--enable-bcmath' '--enable-shmop'
'--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal'
'--enable-mbstring=shared' '--enable-mbstr-enc-trans'
'--enable-mbregex' '--with-apxs2=/usr/sbin/apxs'

-- End --

- Config of Server on which it Fails -

-- Start --

'./configure' '--build=i686-redhat-linux-gnu'
'--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu'
'--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib'
'--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--cache-file=../config.cache'
'--with-config-file-path=/etc'
'--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect'
'--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-db4=/usr'
'--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr'
'--with-png-dir=/usr' '--with-gd=shared' '--enable-gd-native-ttf'
'--without-gdbm' '--with-gettext' '--with-ncurses=shared' '--with-gmp'
'--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png'
'--with-pspell' '--with-xml' '--with-expat-dir=/usr'
'--with-dom=shared,/usr' '--with-dom-xslt=/usr'
'--with-dom-exslt=/usr' '--with-xmlrpc=shared'
'--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU'
'--enable-bcmath' '--enable-exif' '--enable-ftp'
'--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem'
'--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid'
'--enable-yp' '--enable-wddx' '--with-pear=/usr/share/pear'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos'
'--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared'
'--with-snmp=shared,/usr' '--with-snmp=shared'
'--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr'
'--enable-memory-limit' '--enable-shmop' '--enable-calendar'
'--enable-dbx' '--enable-dio' '--enable-mbstring=shared'
'--enable-mbstr-enc-trans' '--enable-mbregex'
'--with-mime-magic=/usr/share/file/magic.mime'
'--with-apxs2=/usr/sbin/apxs'

-- End --

Both the c

Re: [PHP] shared memory

2004-05-19 Thread venkata ramana
Thanks for your reply, but I afraid you did not get my point. I am
talking about shared memory that is used for Interprocess
communication. We can access the shared memory created by one C
program in other C program and same is the case with php. I am trying
to communicate with a C program from php using shared memory, but I
did not get it working till now.

To be more specific, I want to know
1. Are calls to function ftok() return the same key in both php and C
2. Is the function shmop_open() return the same shared memory as
shmget() system call, when we pass the same key to both the functions.
Thanks in advance
ramana.

On Wed, 19 May 2004 15:00:02 +0300, Burhan Khalid <[EMAIL PROTECTED]> wrote:
> 
> 
> venkata ramana wrote:
> > Is the shared memory created with php comaptible with that created
> > with a C program? I mean to ask, can we access the data written into
> > shared memory by a C program from a php program?
> 
> I would hope not, as this would cause major security problems and system
> instability.
> 
> I *believe* once memory has been allocated to a program, it is for its
> exclusive use unless released.  Two programs cannot share the same stack
> space.
> 
> You would also be compromising the data that's in the shared space.
> 
> Burhan
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] shared memory

2004-05-19 Thread Burhan Khalid
venkata ramana wrote:
Is the shared memory created with php comaptible with that created
with a C program? I mean to ask, can we access the data written into
shared memory by a C program from a php program?
I would hope not, as this would cause major security problems and system 
instability.

I *believe* once memory has been allocated to a program, it is for its 
exclusive use unless released.  Two programs cannot share the same stack 
space.

You would also be compromising the data that's in the shared space.
Burhan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] shared memory

2004-05-19 Thread venkata ramana
Is the shared memory created with php comaptible with that created
with a C program? I mean to ask, can we access the data written into
shared memory by a C program from a php program?

Thanks,
ramana.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Shared Memory

2003-03-20 Thread Mincu Alexandru
nope!
of course not there are two different procs.

On Thu, 2003-03-20 at 17:19, Adam Voigt wrote:
> Is the Shared Memory allocated with the SHMOP functions
> persistent? Like when a script ends, on the next call
> of a script, can you read the same memory block and have
> the data be there?
> 
> -- 
> Adam Voigt ([EMAIL PROTECTED])
> The Cryptocomm Group
> My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc
-- 
Mincu Alexandru intelinet.ro
Tel:+4 0745 369719  +4 021 3140021
www.intelinet.ro[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shared Memory

2003-03-20 Thread Adam Voigt
Is the Shared Memory allocated with the SHMOP functions
persistent? Like when a script ends, on the next call
of a script, can you read the same memory block and have
the data be there?

-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Shared Memory in PHP

2002-12-13 Thread Krishnan
Hi all,
   I am new to PHP and would like the expert opinion of this forum on
something that I am trying to do
I have about 500K entries (name,value pairs) for which I want ti implement a
very fast lookup. I have access to an Oracle database server but I am afraid
that it does not have any power to handle the volume.
  Instead I am thinking of loading these entries in shared memory on
each (Apache) web server and look it up from my PHP script. (I have enough
memory on the server to set aside enough shared memory area to hold these
entries).
 Going through the PHP Documentation, I find 2 sets of functions:
  1.shm_attach,shm_put_var,shm_get_var etc.
  2. shmop_open,shmop_write,shmop_read etc.
   Which set of functions is the correct one to use (I am running PHP
4.1.x)
 Ideally, I'd like to implement a hash (to use a PERL term) in
shared memory that is accessible from PHP.
 Is this proposed approach too outrageous?
 Any thoughts on this would be greatly appreciated.

TIA
Krishnan



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Shared Memory Error.

2002-02-18 Thread Lars Torben Wilson

On Sun, 2002-02-17 at 23:34, Paul J. Stevens wrote:
> I am using PHP Version 4.0.4pl1 with an Embedded Linux (PeeWee Linux,
> which is based on Red Hat 6.2 w/ a 2.2.18 Kernel). 
> 
> I have tried using shmop_open(), shm_open() & shm_attach(). All of these
> give an error message of "function not defined".
> 
> It is not clear form the documentation that I have seen on the net and
> in the "PHP Developer's Dictionary" which, if any, 
> of the functions listed above are correct. Nor is it clear what has to
> be done to make the functions "defined". 

>From the PHP Manual (http://www.php.net/shmop):

  To use shmop you will need to compile php with the --enable-shmop   
  parameter in your configure line.


In general, try a './configure --help' in your source tree.


Hope this helps,

Torben

> I have created the shared memory in a "C" program that controls my
> embedded device. I am attempting to create a web 
> page to aid in the control of the embedded device.
> 
> 
> Thanks,
> 
> Paul Stevens

-- 
 Torben Wilson <[EMAIL PROTECTED]>
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Shared Memory Error.

2002-02-18 Thread Paul J. Stevens

I am using PHP Version 4.0.4pl1 with an Embedded Linux (PeeWee Linux,
which is based on Red Hat 6.2 w/ a 2.2.18 Kernel). 

I have tried using shmop_open(), shm_open() & shm_attach(). All of these
give an error message of "function not defined".

It is not clear form the documentation that I have seen on the net and
in the "PHP Developer's Dictionary" which, if any, 
of the functions listed above are correct. Nor is it clear what has to
be done to make the functions "defined". 

I have created the shared memory in a "C" program that controls my
embedded device. I am attempting to create a web 
page to aid in the control of the embedded device.


Thanks,

Paul Stevens

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] read php shared memory with C

2001-12-14 Thread Andrey Hristov

Read zend.h to see the structure of zval (the main zend strucutre).

Regards,
Andrey Hristov
- Original Message -
From: "César Gómez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 13, 2001 10:46 AM
Subject: [PHP] read php shared memory with C


> Hi all,
>
> Any one knows how to read a memory segment shared by php in C?
>
> I know how to read data from shared memory in C when the segment contains a
> (char *) or other type but PHP store the data like a Hash and I don't know
> to read it.
>
> Thanks in advance.
>
> P.D: Sorry for my English
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] read php shared memory with C

2001-12-14 Thread César Gómez

Hi all,

Any one knows how to read a memory segment shared by php in C?

I know how to read data from shared memory in C when the segment contains a
(char *) or other type but PHP store the data like a Hash and I don't know
to read it.

Thanks in advance.

P.D: Sorry for my English




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] shared memory

2001-04-11 Thread Rasmus Lerdorf

One of the things you have to realize is that Apache-1.3.x is is
single-threaded pre-forking multi-process web server.  That means that you
have many processes handling requests.  You never know which process will
take a request, so storing any sort of data in a process won't do much
good as the next request may come in on another process.

This restriction, although somewhat cumbersome, forces you to build web
applications that will automatically be capable of being distributed
across multiple web servers.  If you cache things in a web server process
and the next hit comes in on a completely different machine you are out of
luck.

For the specific example of query caching that you gave, you need to
rethink your approach.  Caching database query results in user space makes
absolutely no sense.  There is no better place to cache query results than
in the database itself.  Leaving such results in the database also allows
you to run multiple web servers against a single large backend database
and still make use of the query cache.

You could put some things in shared memory if you know you will never move
beyond a single server, but shared memory is a limited resource and
somewhat cumbersome to work with.

-Rasmus

On Mon, 9 Apr 2001, Stephen Haberman wrote:

> Hello,
>
> I've recently started PHP development after a few years of working with ASP.
> So far I really like PHP, but am having trouble using some of the techniques
> I had in ASP.  For example, I really like using ASP's Application object to
> cache data in, but I can't seem to have an equivalent in PHP.
>
> (Due note that I'm also new to the Unix/Linux environment, so if I have any
> concepts glaringly wrong, please correct me).
>
> I've read over the System V shared memory functions, but I can't tell if
> these would accomplish what I'm looking to do?
>
> I guess what I really need to learn is how threading and synchronization
> works in Apache/PHP.  I had just mastered COM/ASP's
> single-thread/multi-threaded design and could write shared, multi-threaded
> ATL components that all the ASP pages could read from marshalling and all
> that.
>
> Are there any good resources/docs on the type of architecture PHP uses and
> how to accomplish the above in the Apache/PHP environment?  I've looked
> around at some books, but all I can find is basic
> here's-how-to-do-a-web-page type stuff.
>
> Ideally what I'd like would be an object that would stay loaded in memory
> (in-process) so that PHP scripts could call functions and variables against
> it with minimal overhead (specifically an object that could cache query
> results instead of each page requerying the database).  Is such a thing
> possible?  Or do I have to move over to Servlets/JSP to find this
> functionality?
>
> Thanks!
>
> - Stephen
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Shared Memory weiredness

2001-04-09 Thread Alexander Skwar

Hello.

I don't understand it at all.  I'm trying to cache some data in a shared
memory segment with PHP 4.0.4pl1's shm functions.

I do this like this:



What I don't understand at all is, why I need to add this "$magic_size_shm"
to the "strlen( serialize( $data ) )" value.  The value I need to add seems
to be always between 41 and 49, but it varies depending on the data I want
to store.

According to the manual and the comments there, I'd have thought that it is
enough to just alloc "strlen( serialize( $data ) )" - why is that not so?

Now, before someone suggest to try shmop instead - this is not working at
all.  I've tried the example from the shmop manual page on php.net, and this
totally breaks.  These lines don't work at all on my system:

$shm_size = shmop_size($shm_id);
echo "SHM Block Size: ".$shm_size. " has been created.\n";

For my system, it returns totally varying values which are all WAY below 0,
like -1072562176, or -722337792 or -914554880   Because of that, PHP
cannot access the shmop segment.

This is on a current Mandrake Cooker (beta) system with glibc 2.2.2, kernel
2.4.2 (also tried 2.4.3). PHP was compiled with gcc 2.96.

Someone please help me!

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 1 day 8 hours 43 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] shared memory

2001-04-09 Thread Stephen Haberman

Hello,

I've recently started PHP development after a few years of working with ASP.
So far I really like PHP, but am having trouble using some of the techniques
I had in ASP.  For example, I really like using ASP's Application object to
cache data in, but I can't seem to have an equivalent in PHP.

(Due note that I'm also new to the Unix/Linux environment, so if I have any
concepts glaringly wrong, please correct me).

I've read over the System V shared memory functions, but I can't tell if
these would accomplish what I'm looking to do?

I guess what I really need to learn is how threading and synchronization
works in Apache/PHP.  I had just mastered COM/ASP's
single-thread/multi-threaded design and could write shared, multi-threaded
ATL components that all the ASP pages could read from marshalling and all
that.

Are there any good resources/docs on the type of architecture PHP uses and
how to accomplish the above in the Apache/PHP environment?  I've looked
around at some books, but all I can find is basic
here's-how-to-do-a-web-page type stuff.

Ideally what I'd like would be an object that would stay loaded in memory
(in-process) so that PHP scripts could call functions and variables against
it with minimal overhead (specifically an object that could cache query
results instead of each page requerying the database).  Is such a thing
possible?  Or do I have to move over to Servlets/JSP to find this
functionality?

Thanks!

- Stephen



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] shared memory questions

2001-03-14 Thread Monte Ohrt

Hi,

I have a situation where I'd like to store some data in shared memory as
opposed to repetitive database requests. Basically, I'd read in a
(small) database table and serialize the results into shared mem. I've
read through the semaphore and shared memory documentation, but some
things are left unclear.

1) which is better to use, the shm_* sem_*, or the shmop functions? It
looks like shmop may be easier to use and more efficient.

2) How do I test if a shared memory segment exists, and create one if it
doesn't? Here's a bit of psuedo code I'd like to emulate:

if ( shared mem exists ) {
open shared mem
read data from shared mem
close shared mem
unserialize data
}
else {
do sql query
serialize data
open new shared mem (size of serialized data?)
write data
close shared mem
}


3) What size should the opened shared mem size be? shm_* mentions that
the values are serialized implicitly. Does shmop do this, or does this
need to be serialized first in the PHP code?

4) How do I know what to use for the system id for the memory segment?
What is a "safe" value to use? Is there a valid range? Are there some
ranges I should stay away from?

5) Is there a way to tell the age of a shared memory segment, or must I
do this within the data that is stored?

6) Are there any good examples of usage out there? The one that comes
with shmop doesn't show a way to test if the shared memory segment
exists before trying to create a new one (and how do I open an existing
shared mem segment, not necessarily knowing its size?)


I'm using Sparc Solaris 2.8, if that makes a difference.

Thanks!

--
Monte Ohrt <[EMAIL PROTECTED]>
http://www.ispi.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




AW: WG: [PHP] Shared Memory with Yast-installed mod_php4 from SuSE.

2001-01-24 Thread Thomas Weber

Yea, thank you It worked!

Formerly i used the --with-apache command (wich hasn't worked) and now with
the --with-apxs it works.

Great, thank you very much! :))

--
Thomas


-Ursprüngliche Nachricht-
Von: Christian Reiniger [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 12:15
An: Php-General
Betreff: Re: WG: [PHP] Shared Memory with Yast-installed mod_php4 from
SuSE.


On Wednesday 24 January 2001 09:55, Thomas Weber wrote:
> Thanks Stathis i tried it twice to compile it, ./configure ,
> make, make install. but i don't get a new libphp4.so! I found only
> a libphp4.a wich is 9MB (the original libphp4.so is only 2.5MB .

You forgot the --with-apxs switch to ./configure

Also , try doing a
strip --strip-unneeded libphp4.so
afterwards

--
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offence.

- Edsger W. Dijkstra

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: WG: [PHP] Shared Memory with Yast-installed mod_php4 from SuSE.

2001-01-24 Thread Christian Reiniger

On Wednesday 24 January 2001 09:55, Thomas Weber wrote:
> Thanks Stathis i tried it twice to compile it, ./configure ,
> make, make install. but i don't get a new libphp4.so! I found only
> a libphp4.a wich is 9MB (the original libphp4.so is only 2.5MB .

You forgot the --with-apxs switch to ./configure

Also , try doing a
strip --strip-unneeded libphp4.so
afterwards

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offence.

- Edsger W. Dijkstra

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




WG: [PHP] Shared Memory with Yast-installed mod_php4 from SuSE.

2001-01-24 Thread Thomas Weber



-Ursprungliche Nachricht-
Von: Thomas Weber [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Januar 2001 09:50
An: [EMAIL PROTECTED]
Betreff: AW: [PHP] Shared Memory with Yast-installed mod_php4 from SuSE.


Thanks Stathis i tried it twice to compile it, ./configure , make,
make install. but i don't get a new libphp4.so! I found only a libphp4.a
wich is 9MB (the original libphp4.so is only 2.5MB . can't be the same)
and when i try to load this module (and not the libphp4.so from SuSE) is get
an syntax-error in httpd.conf (SuSE support says this happens when a module
is not functioning.)



Hit Thomas,

you need to recompile PHP with the options you want (as a shared apache
module) and then replace libphp4.so on /usr/lib/apache/ with your own
version.
A good thing is to keep SuSE's version as a backup:-)
Don't forget to restart apache afterwards. (/etc/rc.d/apache stop;
/etc/rc.d/apache start)

A SuSE.6.4 user.

-Stathis.

Thomas Weber wrote:
>
> Hi,
>
> i try to use the shared memory functions on a SuSE Linux 7.0 server with
> Apache and mod_php4 out of the box installed with yast. For shmop i need
to
> configure PHP with --enable-shmop with isn't enabled in this installation.
>
> I know how to enable this when compiling and installing the source of
> mod_php4, what is to difficult for me, i think. But how to enable it in
the
> SuSE-RPM-Distribution? I found a mod_php4.spec in /usr/src/packages/SPECS
in
> wich the configuration options are, butr i don't know how to use it to
> install this RPM with my own configuration. Can anyone help me?
>
> Sincerly,
> ---
> Thomas Weber
>
> CYNOBIA Community Online Service AG
> Kühbachstraße 11
> 81543 München
> fon 089-78 06 0(280)
> fax 089-78 06 01 99
> email [EMAIL PROTECTED]
> net http://www.CYNOBIA.de

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Shared Memory with Yast-installed mod_php4 from SuSE.

2001-01-23 Thread Rouvas Stathis

Hit Thomas,

you need to recompile PHP with the options you want (as a shared apache
module) and then replace libphp4.so on /usr/lib/apache/ with your own
version.
A good thing is to keep SuSE's version as a backup:-)
Don't forget to restart apache afterwards. (/etc/rc.d/apache stop;
/etc/rc.d/apache start)

A SuSE.6.4 user.

-Stathis.

Thomas Weber wrote:
> 
> Hi,
> 
> i try to use the shared memory functions on a SuSE Linux 7.0 server with
> Apache and mod_php4 out of the box installed with yast. For shmop i need to
> configure PHP with --enable-shmop with isn't enabled in this installation.
> 
> I know how to enable this when compiling and installing the source of
> mod_php4, what is to difficult for me, i think. But how to enable it in the
> SuSE-RPM-Distribution? I found a mod_php4.spec in /usr/src/packages/SPECS in
> wich the configuration options are, butr i don't know how to use it to
> install this RPM with my own configuration. Can anyone help me?
> 
> Sincerly,
> ---
> Thomas Weber
> 
> CYNOBIA Community Online Service AG
> K&oacgr;hbachstra&iacgr;e 11
> 81543 M&oacgr;nchen
> fon 089-78 06 0(280)
> fax 089-78 06 01 99
> email [EMAIL PROTECTED]
> net http://www.CYNOBIA.de

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Shared Memory with Yast-installed mod_php4 from SuSE.

2001-01-23 Thread Thomas Weber

Hi,

i try to use the shared memory functions on a SuSE Linux 7.0 server with
Apache and mod_php4 out of the box installed with yast. For shmop i need to
configure PHP with --enable-shmop with isn't enabled in this installation.

I know how to enable this when compiling and installing the source of
mod_php4, what is to difficult for me, i think. But how to enable it in the
SuSE-RPM-Distribution? I found a mod_php4.spec in /usr/src/packages/SPECS in
wich the configuration options are, butr i don't know how to use it to
install this RPM with my own configuration. Can anyone help me?

Sincerly,
---
Thomas Weber


CYNOBIA Community Online Service AG
Kühbachstraße 11
81543 München
fon 089-78 06 0(280)
fax 089-78 06 01 99
email [EMAIL PROTECTED]
net http://www.CYNOBIA.de