Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51036 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83680 invoked from network); 16 Dec 2010 08:28:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Dec 2010 08:28:31 -0000 X-Host-Fingerprint: 95.31.13.88 xdmitri2.static.corbina.ru Received: from [95.31.13.88] ([95.31.13.88:3417] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/E1-59023-9ADC90D4 for ; Thu, 16 Dec 2010 03:28:25 -0500 Message-ID: <91.E1.59023.9ADC90D4@pb1.pair.com> To: internals@lists.php.net References: <1292411981.2128.2.camel@guybrush> Date: Thu, 16 Dec 2010 11:28:22 +0300 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-Posted-By: 95.31.13.88 Subject: Re: [PHP-DEV] Re: PHP Performance in Apache: Multi-Process vs Multi-Threaded From: dmda@yandex.ru ("jvlad") >> No. Php if we talk about php with all its extensions is not threadsafe >> at >> all. Many of the extensions allocate static data and inherently >> non-thread-safe. > > PHP is, if compiled with ZTS/TSRM, thread-safe. Some libraries used by > some extensions might not be thread safe, but basically all "usually" > used ones are thread-safe. While it is a bit complicated as some > libraries could either be compiled thread-safe or not or some might be > not thread-safe on specific systems ... but that's not PHP itself ;-) > > johannes > Dear Johannes, I'm not sure why you repeated what I stated in my post. So I'm repeating it after you too :) Yes, php core is developed with threadsafe techniques in mind, some extensions are safe too, and some extensions which are using 3rd party libraries are definitely not safe. The only thing I'd kindly ask you to pay more attention to is using "usually" word together with "safe" in one sentence. In my opinion they should never be used both if we talk about production servers, or at least servers where crashes are not welcome. Just to illustrate the issue with "usually", do you consider openssl, a widely used php extension, as a "usually threadsafe" extension? If you do, please take a look at this page http://www.openssl.org/docs/crypto/threads.html and these words in particular: OpenSSL can safely be used in multi-threaded applications provided that at least two callback functions are set, locking_function and threadid_func. locking_function(int mode, int n, const char *file, int line) is needed to perform locking on shared data structures. (Note that OpenSSL uses a number of global data structures that will be implicitly shared whenever multiple threads use OpenSSL.) Multi-threaded applications will crash at random if it is not set Do you think any locking function is implemented in openssl php extension? -j