Re: global variable and pconnect trouble in extension

From: Date: Fri, 23 Jun 2000 15:06:23 +0000
Subject: Re: global variable and pconnect trouble in extension
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-22059@lists.php.net to get a copy of this message
Hi again, I have declared this global like the num_persistent in the mysql module (ZEND_BEGIN/END_MODULE_GLOBAL) or in the sybase module (in struct sybase_module). So i can understand what you say if my global is declared as a standard C global, but in this case what is the benefit to use some macro like ZEND_BEGIN/END_MODULE_GLOBAL). If you try my code, the php script display the state of the variable 'num_persistent' and it increment when the second script is launch in another browser window with a different user name. The trouble is when i refreshing the result the second window. With netscape the first time num_persistent = 2, after 5 or 6 refresh num_persistent alternate to 2 or 1. Does it mean that the variable num_persistent used in many database extension can't really control the maximum persistent connexion allowed for all child process ? Before i try to build this extension, i read the apidoc.txt and the zend-apidoc, then i read the (short) devel doc in the php manual. In this newsgroup, i had read that a good example is to read the mysql.c source extension which use many undocumented (maybe unformalised) function and macro. I have try to understand memory management in the php engine, it's not clear for me. What is the memory scope and difference between persistent ressource table (kept between hit eg:apidoc.txt) and zend_hash_xxx functions, the PHP_RINIT and PHP_MINIT, etc... Why use non persistent ressource (php3_list_xxx), is not like global vars.... There is no clean api documentation or 'absolute' code samples. Of course, i'am stupid. May be the solution is to read the entire zend source code before build a clean ext. Thanks for you help, Chesneau Serge Andreas Karajannis wrote: > Chesneau Serge wrote: > > > > Hi, > > > > Some trouble with global. > > I wrote a test module called ats. In this module, i need a mechanism > > like persistent database connexion witch use a global variable > > (num_persistent) that count the number of new permanent connexion. It > > seem that this counter (num_persistent) is not refreshing (or storing) > > correctly. My extension has two fonction. One for register user in the > > hash list (ats_register), the second for showing num_persistent and the > > hash content. When i call two php script (ats2.php and ats3.php) with > > two browser window and refreshing (5/6 time), the result is strange. > > I think that a correctly write my module but, if the global variable > > (num_persistent) can't correctly be set, i think that allocation storing > > in the hash table can be wrong, ... but i'am a newbie. > > > > Your global variable is only a per-process global variable. > Since apache is a multi-process server, each of the child processes that > respond to requests have their own instance of this variable. > See the discussion on persistent connections in the manual for more > information. > > -Andreas > > -- > Andreas Karajannis > GMD National Research Center for Information Technology > Schloss Birlinghoven, D-53754 Sankt Augustin > Phone +49 2241 142948 > > -- > 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

« previous php.dev (#22059) next »