Re: [PHP4BETA] CVS update: php4/ext/session

From: Date: Sun, 06 Jun 1999 21:15:41 +0000
Subject: Re: [PHP4BETA] CVS update: php4/ext/session
References: 1 2 3 4 5 6 7 8  Groups: php.version4 
Request: Send a blank email to php-version4+get-1343@lists.php.net to get a copy of this message
At 22:09 06/06/99 , Sascha Schumann wrote:
On Sun, Jun 06, 1999 at 11:05:27PM +0200, Zeev Suraski wrote: Ah, but it doesn't yet use that function for ZTS (there's no ts_allcoate_id() call, none I could find easily anyway). Future planning? Well, I just saw that ZTS only requires a per module initialization function. The one we are talking about is a per request init function. I still fail to see a reason for changing the ps_globals->x to PS(x). Andi?
Generally, the thread safety approach works like this. In thread unsafe mode, never pass around your global struct. Always use the XS() macro, and the relevant XLS_FETCH(). Do that, and put the right XLS_C/XLS_CC/XLS_D/XLS_DD - and you pretty much got thread safety going for you. The only exception to the rule, perhaps, is when you need the global structure to be initialized on a per-thread basis, 'just in time', when it's created for the first time in a new thread. You can supply ts_allocate_id() with a constructor function a destructor function, that initialize that global structure for you. In that case, you have to write a function that takes a pointer to your global struct and initializes it, and supply ts_allocate_id() with it. It would then make sense to reuse that function in order to initialize your global structure in thread-unsafe mode, by explicitly calling it and passing the global struct address to it. I'm dead tired so I'm not looking at session.c right now. Generally, you should be using TSRM's 'JIT' initialization if you have 'complex' members in your global struct, such as hashes. (BTW, AFAIK Andi went to sleep, so if you want to revert any changes, I recommend you do it yourself and not wait for him...) Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il

« previous php.version4 (#1343) next »