Hi,
I am sorry if this was discussed before, but the search on "MINIT" didn't
return any result.

I work on a PHP extension and found out some strange (possibly not, that is the
question) behaviour of global variables in PHP:

1. PHP 4.2.1, WinXP English (build 2600), ZTS=1, DEBUG=0, PHP as an Apache
1.3.26 module
2. Declare and initialize a TSRM global variable: int variable_name
3. Inside PHP_MINFO_FUNCTION (actually, this could be any other func) I print
out: ++(TSRM_G(variable_name)); (of course, I use the macro defined in
php_myextension.h instead of TSRM_G)
4. Reload phpinfo() page => In extension's info table appear a number which is
incremented on every page's reload. Untill now everything's like OK.

The problem appear when you reload the page a bit faster (i.e. 2-3 times per
second). It seems like Apache creates another child (it has to do so, hasn't
it?) and PHP calls PHP_MINIT_FUNCION() (where all globals are being
reinitialized) for the new Apache's thread. Further, all Apache's threads
appear to be totally independent because from time to time the number from the
first thread appears on the page.

I didn't test this on *NIX.

Now questions:
* WHY does PHP call the module's init funcion various times instead of calling
it once only when Apache initializes?
* Is this an expected behaviour or something really goes wrong?
* This seems to be an Apache's fault, not PHP one. Is this correct?

I hope I described the problem clearly. If not, ask me for more information.
Thanks for your time,
    Maxx


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to