Re: Embedding PHP, few additional questions.
| From: | Ingwie Phoenix | Date: | Fri, 27 Jun 2014 05:57:57 +0000 |
| Subject: | Re: Embedding PHP, few additional questions. | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75109@lists.php.net to get a copy of this message | ||
Am 26.06.2014 um 12:14 schrieb Johannes Schlüter <johannes@schlueters.de>:
> Hi,
>
>
> On Thu, 2014-06-26 at 11:50 +0200, Ingwie Phoenix wrote:
>> I am working on a nodejs module that allows to embed PHP (to use it
>> within HTTP servers, for example). I wish to extend with a small
>> thing. Instead of starting, running and shutting down the engine, I
>> would like to keep it running, and just reset its state. Why? I
>> *think* that this would keep my OPCache. Sadly, I did not find any
>> documentation on how OPCache saved its…cache. Its just ment as a
>> matter of speed improvement.
>>
>> How can I just reset the engine, without shutting it down?
>
> I don't now what you mean by "reset" PHP is meant to serve requests, one
> after another, where each request has its own context. Probably youwant
> to run request cycles?
>
>> The embedding instructions that I will use are here:
>> http://phi.lv/?p=376
>
> This sees to use the high level embed APIs. Use
> php_request_startup(TSRMLS_C); ... php_request_shutdown((void *) 0);
> style loops. See embed API implementation, and a simple SAPI like
>
> https://github.com/johannes/pconn-sapi/blob/master/pconnect-sapi.c#L180
>
> johannes
Hey.
So I just looked into the pconn source and SAPI that you linked. Its basically easy, if there wasnt
the rather confusing tsrm bits here and there. But I think I would just copy them…
I also did some research, and learned that OPCaches are stored in shared memory. Wouldn’t shared
memory get lost when the interpreter is shut down, or how is this working? Is shared memory actually
„fully associated“ to a program? Excuse me for the dumb question, It is just my first direct
confrontation with shared memory, ever.
In your pconn SAPI, you are telling PHP that you are not going to use headers… but, in my case, I
have an incomming HTTP request and should very much forward those headers. What is the function that
I must look at, to copy my headers?
As this is going to be a nodejs module (v8php), I will link most of these functions into JS scope by
supplying wrappers and the like. Going to be pretty interesting to see this in actual work, and
comparign the speed to just using child_process.spawn.
Kind regards, Ingwie.