Re: Thread-safety & globals
| From: | Andi Gutmans | Date: | Thu, 05 Oct 2000 04:16:33 +0000 |
| Subject: | Re: Thread-safety & globals | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-34279@lists.php.net to get a copy of this message | ||
At 03:40 AM 10/5/00 +0300, Jouni Ahto wrote:
I'm a bit in the dark here... threads are something I understand approximately NULL about. But before releasing 4.0.3, I'd really like to fix one thing in InterBase module, because there seems to be some severe problems with the Windows .dll -version (there are some others too... :( , but their fix will wait until 4.0.3 is out). Now, the problem is that unlike all the other database modules, InterBase module still has le_link, le_plink etc. types as part of a structure, created with the macro ZEND_BEGIN_MODULE_GLOBALS(ibase) ... etc. I could have misunderstood the whole way how a module should initialize itself (see bug id 6883) in a multithreaded environment. Is that the right way?Check out the MySQL module. le_link, le_plink and friends are registered types. These should be true globals and should sit in interbase.c (with a note that they should be true globals even in a multi-threaded environment) and be only initialized on MINIT() once. The rest of the per-thread variables should be in the ZEND_BEGIN_MODULE_GLOBALS(...) section like you mentioned.
Or, I had the opportonity on the last summer to test an evaluation version of Zeus (a multihreaded server working also on Linux), there were some problems there too, but after some testing and defining all of the list entry types to static int instead of keeping them in a module global struct, they disappeared. I know that this approach works and it's the same that all the other database modules use. So, unless I've been told otherwise, I'll commit a version working that way within the next 12 hours and I'd really like to see that end up in 4.0.3.Yes as I mention above this is the right way to do it. You're only supposed to mention the tyes once.
I think I'll commit that version even if I'm told otherwise. The file EXTENSIONS says I'm the primary maintainer of that module. So anything that happens is in any case my fault, and with the new version, I'd guess there'll be a lot of less complaints and bug reports.Just make sure you test it first to see that it works :) Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/