Re: Problem with globals ZTS

From: Date: Thu, 05 Jul 2001 06:47:39 +0000
Subject: Re: Problem with globals ZTS
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-58950@lists.php.net to get a copy of this message
Hello,

I'm in ZTS mode. Building with VC++ 5, on win 98 with PHP 4.0.5 and apache
1.3.19.

Do you have any clue for this problem ? Thank you in advance cause I'm
stucked.

Gilles

----- Message d'origine -----
De : "Zeev Suraski" <zeev@zend.com>
À : "Gilles Koffmann" <gko@chez.com>
Cc : <php-dev@lists.php.net>
Envoyé : samedi 23 juin 2001 10:30
Objet : Re: [PHP-DEV] Problem with globals ZTS


> Are you building it in ZTS mode or does it crash in non ZTS mode after
this
> change?
>
> At 09:35 22/6/2001, Gilles Koffmann wrote:
> >Hi,
> >
> >I'm writing an extension to php. After changing my code to have thread
safe
> >globals ,
> >my extension is crashing and I can't figure out what it is:
> >
> >typedef struct {
> >  HashTable array_dl_handle; /* hash user dll name -> handle, getobject,
> >getcompiler, destroyobject */
> >  HashTable array_compiler;  /* hash compiler name -> handle, gps, gms,
> >version */
> >} php_delphi_globals;
> >
> >#ifdef ZTS
> >#define DG(v) (delphi_globals->v)
> >#define DG_FETCH() php_delphi_globals *delphi_globals =
> >ts_resource(delphi_globals_id)
> >#define DG_D       php_delphi_globals *delphi_globals
> >#define DG_DC      , DG_D
> >#define DG_C       delphi_globals
> >#define DG_CC      , DG_C
> >int delphi_globals_id;
> >#else
> >#define DG(v) (delphi_globals.v)
> >#define DG_FETCH()
> >#define DG_D
> >#define DG_DC
> >#define DG_C
> >#define DG_CC
> >php_delphi_globals delphi_globals;
> >#endif
> >
> >#ifdef ZTS
> >static void alloc_delphi_globals_ctor(php_delphi_globals *delphi_globals)
{
> >   memset(delphi_globals, 0, sizeof(php_delphi_globals));
> >}
> >#endif
> >
> >ZEND_MINIT_FUNCTION(delphi) {
> >#ifdef ZTS
> >   delphi_globals_id = ts_allocate_id(sizeof(php_delphi_globals),
> >     (ts_allocate_ctor)alloc_delphi_globals_ctor, NULL);
> >#endif
> >...
> >
> >  DG_FETCH();
> >  zend_hash_init(&DG(array_dl_handle), 0, NULL, NULL, 0);
> >  zend_hash_init(&DG(array_compiler), 0, NULL, NULL, 0);
> >....
> >}
> >
> >It crashes when I do in one function:
> >
> >DG_FETCH();
> >zend_hash_find(&DG(array_dl_handle), module_name,strlen(module_name)+1,
> >(void **)&value);
> >
> >My hashtable is empty.
> >When array_dl_handle was not part of ZTS globals, everything was OK. Any
> >clue ?
> >
> >Gilles.
> >
> >
> >
> >
> >--
> >PHP Development Mailing List <http://www.php.net/>
> >To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-dev-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> Zeev Suraski <zeev@zend.com>
> CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/
>



Thread (5 messages)

« previous php.dev (#58950) next »