Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15228 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44166 invoked by uid 1010); 28 Feb 2005 13:37:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 44103 invoked by uid 1007); 28 Feb 2005 13:37:12 -0000 To: internals@lists.php.net Organization: The Man from S.P.U.D. Date: Mon, 28 Feb 2005 07:37:11 -0600 Message-ID: <2005022807371112877%drbob@TheManFromSPUDcom> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Unison/1.5.2 X-Posted-By: 68.22.220.206 Subject: How to embed PHP5 into multi-threaded C app? From: drbob@TheManFromSPUD.com (Bob Beaty) All, I've searched the web for this answer and I'm stumped. I can't find the answers. So I thought I'd try the lists. Here goes: I have seen how to embed PHP 5 using the code like: ... php_embed_module.ub_write = my_ub_write_func; php_embed_module.log_message = my_log_func; php_embed_module.sapi_error = my_error_log; ... zend_eval_string(...); ... And from this, I looked in the code to see that php_embed_module is a static variable that's used in the initialization methods so it *seems* as though this can't possibly be thread-safe. Yet web servers do it all the time. I read on the web that the global variables for the PHP engine are maintained in the thread where they were originally defined. This leads me to believe that there's the possibility that the php_embed_module and other important variables might be thread-local storage, and therefore thread-safe. Yet if that were the case, how does one define different write, log, and error functions so that the engine of one thread does not interfere with another? In general, my problem is this: I have a multi-threaded C++ app that I want to embed the PHP 5 engine into. I have read up how to create extensions to PHP, and will do that as necessary, but I need to be able to call this engine from my code and capture stdout, stderr, etc. Can I do this with PHP 5.0.3 as it exists now? Are there special things I need to watch out for? Any pointers, FAQ sites, etc. that I can look at would be most helpful. -- Thanks, Bob (drbob@TheManFromSPUD.com) The Man from S.P.U.D. We will write no code before it's designed.