internals:engine

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
internals:engine [2010/05/19 17:06]
philip Added "How do I detect the SAPI" as explained by Johannes
internals:engine [2017/09/22 13:28] (current)
Line 49: Line 49:
   [11:59am] scoates: and the hashtable will automatically grow on _add, right? the length passed to init is just a hint?   [11:59am] scoates: and the hashtable will automatically grow on _add, right? the length passed to init is just a hint?
   [11:59am] johannes_: right   [11:59am] johannes_: right
- 
 ===== Unsorted ===== ===== Unsorted =====
  
 Add your random stuff here. I'll move it/update it/fix it (Derick) Add your random stuff here. I'll move it/update it/fix it (Derick)
 +
 +How to get %%__LINE__ and __FILE__%%?
 +  * zend_get_executed_filename() and zend_get_executed_lineno()
  
 How do I detect the SAPI? How do I detect the SAPI?
Line 112: Line 114:
 </​code>​ </​code>​
  
-Note: do not use ZEND_INIT_MODULE_GLOBALS/​ts_allocate_id. If used a shared extension, they will provoke an attempt to call the destructor after the module has been unloaded!+Note: do not use ZEND_INIT_MODULE_GLOBALS/​ts_allocate_id. If used a shared extension, they will provoke an attempt to call the destructor after the module has been unloaded! ​Also, for all that is holy, do NOT initialize globals on MINIT (EXTNAME_G(var_ptr) = NULL), that won't work correctly in ZTS as it won't initialize the value in all threads.
  
 - Now define the constructor and destructor functions: - Now define the constructor and destructor functions:
Line 127: Line 129:
 } }
 </​code>​ </​code>​
 +
 +The globals constructor and destructor are NOT execute per-request,​ they are part of the module startup/​shutdown. The globals can store data across requests. If you need to do per-request operations to the globals, use module-activate and module-deactivate callbacks.
  
 Note: ZEND_MODULE_GLOBALS_CTOR_D will declare a function as receiving a zend_extname_globals*,​ not void* and zend_module_entry is supposed to contain a function pointer type that receives void*. I think this violates the C standard (the declarations are incompatible),​ but should however by safe since the arguments have the same size. Note: ZEND_MODULE_GLOBALS_CTOR_D will declare a function as receiving a zend_extname_globals*,​ not void* and zend_module_entry is supposed to contain a function pointer type that receives void*. I think this violates the C standard (the declarations are incompatible),​ but should however by safe since the arguments have the same size.
internals/engine.1274288790.txt.gz · Last modified: 2017/09/22 13:28 (external edit)