Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28227 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84154 invoked by uid 1010); 4 Mar 2007 19:01:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84138 invoked from network); 4 Mar 2007 19:01:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2007 19:01:27 -0000 Authentication-Results: pb1.pair.com header.from=edin@krug.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=edin@krug.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain krug.dk from 82.103.137.104 cause and error) X-PHP-List-Original-Sender: edin@krug.dk X-Host-Fingerprint: 82.103.137.104 khaled.krug.dk Received: from [82.103.137.104] ([82.103.137.104:55572] helo=khaled.krug.dk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/B5-46646-4871BE54 for ; Sun, 04 Mar 2007 14:01:26 -0500 Received: from latif.krug.dk (latif.krug.dk [90.184.100.94]) by khaled.krug.dk (Postfix) with ESMTP id E7B36B4004C; Sun, 4 Mar 2007 20:01:21 +0100 (CET) Received: by latif.krug.dk (Postfix, from userid 504) id B1BD024600CE; Sun, 4 Mar 2007 20:01:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on latif.krug.dk X-Spam-Level: X-Spam-Status: No, score=-4.4 required=4.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.8 X-Spam-Detected: no Received: from [10.0.0.5] (blaster.intra.krug.dk [10.0.0.5]) by latif.krug.dk (Postfix) with ESMTP id 5383A24600C7; Sun, 4 Mar 2007 20:01:19 +0100 (CET) Message-ID: <45EB1780.5080006@krug.dk> Date: Sun, 04 Mar 2007 20:01:20 +0100 User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Michael Vergoz CC: PHP Internals List References: <008c01c75c05$b6584ae0$070110ac@michaelb651094> In-Reply-To: <008c01c75c05$b6584ae0$070110ac@michaelb651094> X-Enigmail-Version: 0.94.1.0 OpenPGP: id=157D0FA8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Thread safe problem on module_registry (Zend API Feature/Change request) From: edin@krug.dk (Edin Kadribasic) Hi Michael, Making dl() work on threaded platforms would be nice. Illustrating your idea with a patch would be very helpful. Edin Michael Vergoz wrote: > Hi > I am currently developing a kind of application server based on PHP > language. > I use modifications I made on SAPI embed/. > I use threads massively. > > In my application design, every thread can load different PHP modules. In > practise, modules are loaded just before php_request_startup() and they are > unloaded after php_request_shutdown() > > The problem I face is that I randomly receive PHP warnings : >
> Warning: Module 'X7V3' already loaded in Unknown on line > 0
>
> Warning: Function registration failed - duplicate name - > XXXXXXXXXXXXXXXXXX in Unknown on line 0
>
> Warning: X7V3: Unable to register functions, unable to load in > Unknown on line 0
> I looked at Zend/zend_API.c and I realized that 2 variables, "module_count" > and "module_registry", are not thread safe and that there is a comment > recomending mutex use for these 2 variables. > > I had asked for a Feature/Change request on bugs.php.net (#40668) but it has > been closed :s > > Then I learnt (thank you Tony) that dl() function is deactivated in ZTS > mode and I also learnt from Tony that this kind of problem was not a > priority ... > > I think it is important to settle this problem at least for IIS and Apache > Threadpool/Worker servers. > > At last, I would like to share my view on ZTS vs mutex use : > > Mutex : > pros : uses slightly less memory > cons : does not give possibility to create module spaces by thread - uses > more processor resource (as there is a mutualized lock for various threads) > > ZTS : > pros : possibility to create module spaces - less processor > cons : slight impact on memory > > This is why I propose to use a ZTS resource instead of mutex to make > "module_registry" thread safe. > > The use of ZTS resources will give a thread the ability to have its own > module HashTable. > > In both cases (mutex or ZTS resource), we will be able to reactivate the > dl() function in ZTS mode. > > I propose to develop the ZTS version resource. Or shall I let you do it ? > > Kind regards > > Michael Vergoz