Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
Are you sure you shouldn't be using zval_ptr_dtor(args[0]) as opposed to zval_dtor(). I see you guys doing this a lot and usually you'd want to use zval_ptr_dtor(). It reduces reference count and only if the zval really needs freeing does it run zval_dtor() and efree(). In any case, you guys seem to forget the final free. Andi At 11:34 PM 2/25/2001 +, David Guerizec wrote: >davidg Sun Feb 25 15:34:48 2001 EDT > > Modified files: > /php4/ext/midgard midgard.c > Log: > force user to pass $xparam by reference (from mgd_walk_xxx_tree() > functions) > > >Index: php4/ext/midgard/midgard.c >diff -u php4/ext/midgard/midgard.c:1.18 php4/ext/midgard/midgard.c:1.19 >--- php4/ext/midgard/midgard.c:1.18 Sun Feb 25 11:31:17 2001 >+++ php4/ext/midgard/midgard.c Sun Feb 25 15:34:48 2001 >@@ -1,4 +1,4 @@ >-/* $Id: midgard.c,v 1.18 2001/02/25 19:31:17 davidg Exp $ >+/* $Id: midgard.c,v 1.19 2001/02/25 23:34:48 davidg Exp $ > Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]> > Copyright (C) 2000 The Midgard Project ry > Copyright (C) 2000 Emile Heyns, Aurora SA <[EMAIL PROTECTED]> >@@ -751,22 +751,28 @@ > zval ** xp = (zval **)xparam; > zval *return_value; > >+ if(!PZVAL_IS_REF(xp[0])) { >+ /* DG: Do we force the user to pass it by reference ? */ >+ php_error(E_WARNING,"You must pass the fourth parameter by >reference."); >+ return; >+ } > ALLOC_ZVAL(return_value); ZVAL_NULL(return_value); > ALLOC_ZVAL(args[0]);ZVAL_LONG(args[0], id); > ALLOC_ZVAL(args[1]);ZVAL_LONG(args[1], level); >- args[2] = xp[0];// DG: is this needed ? -> >- zval_copy_ctor(args[2]); >+ args[2] = xp[0];// DG: is this needed ? >->zval_copy_ctor(args[2]); > > if(call_user_function(CG(function_table), NULL, > xp[1], return_value, 3, > args) != SUCCESS) { > php_error(E_WARNING,"Unable to call %s() - function does > not exist", > (xp[1])->value.str.val); >+ zval_dtor(return_value); >+ zval_dtor(args[0]); zval_dtor(args[1]); > return; > } >+ > zval_dtor(return_value); >- zval_dtor(args[0]); >- zval_dtor(args[1]); >+ zval_dtor(args[0]); zval_dtor(args[1]); > } > > #if YOU_WANT_TO_TEST > > > >-- >PHP CVS Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
On Thu, Feb 22, 2001 at 01:38:36PM +0200, Andi Gutmans wrote: > Because thread-wide globals are only available when you're actually in the > thread (during a request) and not when the process starts up. If you need > true globals you can just use globals. sorry - you're right (and i'm stpid:-) forgot about the fact that MINIT is ony called once. you of course have to initialize your globals in your TSRM'ized _ctor funtion like this: static void php_assert_init_globals(ASSERTLS_D) { ASSERT(callback) = 0; } PHP_MINIT_FUNCTION(assert) { #ifdef ZTS assert_globals_id = ts_allocate_id(sizeof(php_assert_globals), (ts_allocate_ctor) php_assert_init_globals, NULL);#else php_assert_init_globals(ASSERTLS_C); #endif stupid me... tc > > Andi > > At 12:34 PM 2/22/2001 +0100, Thies C. Arntzen wrote: > >On Thu, Feb 22, 2001 at 01:26:45PM +0200, Andi Gutmans wrote: > > > You only have the module globals during requests (rinit/rshutdown). You > > > can't access them in module init/module shutdown. > > > > could you explain why? ok the the midgard PHP_MINIT_FUNCTION > > does not allocate a tsrm_id for the module (which is wrong) > > but apart from that i see no reason why the globals should > > not be available all-time. > > > > tc > > > >-- > >PHP CVS Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
Yes. It will call your init_globals just in time, usually on your first access to the data if I remember correctly. Your fix is correct. I didn't see it when I sent that Email. Andi At 12:37 PM 2/22/2001 +0100, Emiliano wrote: >Andi Gutmans wrote: > > > > You only have the module globals during requests (rinit/rshutdown). You > > can't access them in module init/module shutdown. > >Yeah, I realized that moments later and removed it. But >ZEND_INIT_MODULE_GLOBALS >will call the init_globals function before the request starts, right? > > > > PHP_MINIT_FUNCTION(midgard) > > > { > > > MidgardClassPtr *midgard_class; > > >+ > > >+ MGDLS_FETCH(); > > >+ MGDG(rcfg) = NULL; > > >+ MGDG(dcfg) = NULL; > > > > > > ZEND_INIT_MODULE_GLOBALS(midgard, php_midgard_init_globals, > NULL); > >Emile > >-- >PHP CVS Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
Because thread-wide globals are only available when you're actually in the thread (during a request) and not when the process starts up. If you need true globals you can just use globals. Andi At 12:34 PM 2/22/2001 +0100, Thies C. Arntzen wrote: >On Thu, Feb 22, 2001 at 01:26:45PM +0200, Andi Gutmans wrote: > > You only have the module globals during requests (rinit/rshutdown). You > > can't access them in module init/module shutdown. > > could you explain why? ok the the midgard PHP_MINIT_FUNCTION > does not allocate a tsrm_id for the module (which is wrong) > but apart from that i see no reason why the globals should > not be available all-time. > > tc > >-- >PHP CVS Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
Andi Gutmans wrote: > > You only have the module globals during requests (rinit/rshutdown). You > can't access them in module init/module shutdown. Yeah, I realized that moments later and removed it. But ZEND_INIT_MODULE_GLOBALS will call the init_globals function before the request starts, right? > > PHP_MINIT_FUNCTION(midgard) > > { > > MidgardClassPtr *midgard_class; > >+ > >+ MGDLS_FETCH(); > >+ MGDG(rcfg) = NULL; > >+ MGDG(dcfg) = NULL; > > > > ZEND_INIT_MODULE_GLOBALS(midgard, php_midgard_init_globals, NULL); Emile -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
On Thu, Feb 22, 2001 at 01:26:45PM +0200, Andi Gutmans wrote: > You only have the module globals during requests (rinit/rshutdown). You > can't access them in module init/module shutdown. could you explain why? ok the the midgard PHP_MINIT_FUNCTION does not allocate a tsrm_id for the module (which is wrong) but apart from that i see no reason why the globals should not be available all-time. tc -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-CVS] cvs: php4 /ext/midgard midgard.c
You only have the module globals during requests (rinit/rshutdown). You can't access them in module init/module shutdown. Andi At 11:35 PM 2/20/2001 +, Emiliano Heyns wrote: >emile Tue Feb 20 15:35:35 2001 EDT > > Modified files: > /php4/ext/midgard midgard.c > Log: > Initialize globals to NULL at module init > > >Index: php4/ext/midgard/midgard.c >diff -u php4/ext/midgard/midgard.c:1.5 php4/ext/midgard/midgard.c:1.6 >--- php4/ext/midgard/midgard.c:1.5 Sun Feb 18 10:45:24 2001 >+++ php4/ext/midgard/midgard.c Tue Feb 20 15:35:35 2001 >@@ -1,4 +1,4 @@ >-/* $Id: midgard.c,v 1.5 2001/02/18 18:45:24 davidg Exp $ >+/* $Id: midgard.c,v 1.6 2001/02/20 23:35:35 emile Exp $ > Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]> > Copyright (C) 2000 The Midgard Project ry > Copyright (C) 2000 Emile Heyns, Aurora SA <[EMAIL PROTECTED]> >@@ -319,6 +319,10 @@ > PHP_MINIT_FUNCTION(midgard) > { > MidgardClassPtr *midgard_class; >+ >+ MGDLS_FETCH(); >+ MGDG(rcfg) = NULL; >+ MGDG(dcfg) = NULL; > > ZEND_INIT_MODULE_GLOBALS(midgard, php_midgard_init_globals, NULL); > /* Remove comments if you have entries in php.ini > > > >-- >PHP CVS Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]