Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38077 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82900 invoked from network); 2 Jun 2008 10:30:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2008 10:30:28 -0000 Received: from [127.0.0.1] ([127.0.0.1:1093]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 35/C0-12632-4CBC3484 for ; Mon, 02 Jun 2008 06:30:28 -0400 X-Host-Fingerprint: 89.79.39.63 chello089079039063.chello.pl Received: from [89.79.39.63] ([89.79.39.63:27249] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/31-65024-6EEB3484 for ; Mon, 02 Jun 2008 05:35:35 -0400 Message-ID: To: internals@lists.php.net Date: Mon, 02 Jun 2008 11:35:30 +0200 User-Agent: Thunderbird 2.0.0.14 (X11/20080502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 89.79.39.63 Subject: Global structures in extension From: adam@klobukowski.pl (Adam Klobukowski) Hello I'm writing a PHP extension where I'm using a custom library. This library uses a structure that needs to be initialized once per server instance. First I initialized it in each of my functions and deinitialize it ant the end. It works ok, but unfortunetly it turns to be to slow. So, I'm trying to do it globally. Everything in that library is internally synchronized, so I don not have to worry about thread safety. I declare my structure globally (in fact a pointer to a structure), initialize it in PHP_MINIT (it works), then deinitialize in PHP_MSHUTDOWN (works too). Unfortunetly, when I'm trying to use this structure in my PHP_FUNCTIONs, it does not work. What i don't know, if PHP magic does something that prevents using such globals. Should I use global resources for that instead? Btw. I'm looking for a good reference of internal PHP APIs. I found excelent Sara's Golemon articles, but thats all, is there anything better? -- Semper Fidelis Adam Klobukowski adam@klobukowski.pl