Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15244 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63738 invoked by uid 1010); 2 Mar 2005 17:48:02 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 63573 invoked from network); 2 Mar 2005 17:47:54 -0000 Received: from unknown (HELO php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2005 17:47:54 -0000 X-Host-Fingerprint: 213.131.2.2 nsrd.sinp.msu.ru Linux 2.4/2.6 Received: from ([213.131.2.2:1560] helo=nsrd.sinp.msu.ru) by pb1.pair.com (ecelerity HEAD r(5124)) with SMTP id 65/43-50616-A4CF5224 for ; Wed, 02 Mar 2005 12:47:54 -0500 Received: from vvs_php (helo=localhost) by nsrd.sinp.msu.ru with local-esmtp (Exim 4.30) id 1D6YGu-0002Yk-CP for internals@lists.php.net; Wed, 02 Mar 2005 21:08:32 +0300 Date: Wed, 2 Mar 2005 21:08:32 +0300 (MSK) To: internals@lists.php.net In-Reply-To: <729eaf208f6ab01379951b88d8f90b76@gmail.com> Message-ID: References: <2005022807371112877%drbob@TheManFromSPUDcom> <42233717.9050107@akbkhome.com> <729eaf208f6ab01379951b88d8f90b76@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: Re: [PHP-DEV] How to embed PHP5 into multi-threaded C app? From: vvs_php@nsrd.sinp.msu.ru (Vadka) On Mon, 28 Feb 2005, Bob Beaty wrote: > Which is my concern. > > I've looked at the code differences, and it appears that this modification > works for running different source files through the engine, but I'm > concerned about the safety of zend_eval_string() if I initialize the engine > in one thread and then try to have several threads calling zend_eval_string() > on different strings. It will not work, as I can see. It works fine, when I do some preparations, like: thr=pthread_self(); tsrml=ts_resource_ex(0, &thr); php_request_startup(tsrml); zend_eval_string(" But, I must note, that there are no waits for the "thread to start current thread" in the parent thread in my situation. Maybe, the code above is not correct (I'm new to PHP's internals), but it works correctly. > I'm not convinced that simply making the php_embed_module thread-local is > going to work either. I'm concerned that the engine was written with the idea > that only one thread can be initializing the php_embed_module and making > calls to zend_eval_string(). If this is the case, then I'd have to re-write a > lot more than php_embed.c to get thread-safety out of the engine. > Or am I on the wrong track? Imagine, we have (usually) situation, when we are running a function in a separate thread (such idea is partially realized in pecl/threads). So, if there are several threads working with one parsed script, we need to provide a kind of task context for each thread + mechanics for sync/async methods. ...maybe, I'm on the wrong track.... :)