|
Posted by tlo on 03/07/07 17:45
"Steve" <no.one@example.com> wrote:
>"thomas" <thomas_bagnino@hotmail.com> wrote in message
>news:part1of1.1.7mnbZt2VDWEsFA@ue.ph...
>| Hi,
>|
>| I'm writting an extension in c for php. Looking at the life cycle of the
>| extensions it looks like each extension is started up within its own
>thread -
>| is this correct?
>
>it depends on what os you're running it on. linux and windows have different
>aproaches to threading and process space. it also depends on how you write
>your c code (which can be accessed across different processes and
>threads...if you make it so).
I'm running on Linux
>| When each request comes in for the extension is seperate thread then
>handling
>| the request? My problem is that I would like to obtain a unique id in a c
>| function in the extension, which would be used in conjunction with a
>message
>| queue for IPC, but I'm not sure how the concurrency works in the php
>framework.
>
>it is os dependent. why not test your theory be putting an interface in your
>lib that essentially returns the thread id? not only would that answer your
>question, it could also be used as your unique id.
I tried doing this, but couldn't get it to work. I managed to do it with
getting the PID, which returns
the pid of the webserver. Help/example on how to get the thread id from the
process would be appriciated
my function in the extension at the moment only returns a string so not much
code just now.
>| The basic extension should send a message to message queue when a request
>comes
>| in and the message should contain a unique id to identify the request in
>order
>| for the message server to send a response to the correct request.
>
>why not just make this simple and use a db? there's your unique id and
>messaging queue no matter what process or thread. if you must though, and
>you're on windows...have your c code create a named-pipe with a static path.
>that would be accessible accross threads and process space as well.
>
I was hopping to do it without the database since I'm running on a low spec
platform and would like
to aviod running the database engine. This was the reason for trying out the
message queing from the extension
>| is there any reason for why this shouldn't be possible?
>
>tons...mostly ones own lack of experience or imagination.
>
>| Any help or links would be greatly appriciated.
>
>if you described what you were trying to do, what the functional
>requirements are, and what os's you are intending to support, we would be of
>greater service.
As this is a proof of concept I haven't really got any detailed requirements,
however as a proof if concept I'm trying to setup a
process which runs as a daemon. The deamon process sets up the incoming message
queue (system V IPC) and then sits and waits for
meassges from the extensions. The extensions function when called, should send
a basic message (could be as basic as an integer and the extesions unique id).
When the message is recived by the daemon it should print it out or write it to
a file.
Eventually I would like to be able to setup a two way communcation on using two
queues. Such that when the daemon process has received a message it does some
processing and then sends it onto an outgoing queue which all the extensions
that are waiting for a reply message listens to. In the response message the
unique thread id is then used to identfy the recipient extension the message is
for.
If I could get something like this working it would be brilliant, any help
would be brilliant
Thanks
TLO
Navigation:
[Reply to this message]
|