Hello Stanislav,

Sunday, July 20, 2003, 12:20:09 PM, you wrote:

DR>>> doesn't work (because the destructor is called from
DR>>> request_shutdown). I'm pretty sure that there is some way to get this
DR>>> working in a decent way... which might perhaps not be the nicest
DR>>> solution.

SM> The problem is that we have following set of requirements:
SM> 1. Modules should be shut down before destructors are called
SM> 2. Modules shutdown should free module resources
SM> 3. Some modules shutdown should "shut down" subsystems they implement
SM> 4. Destructors should not use other objects they don't have direct link to 
SM> - such as global objects, etc.

SM> Due to 1 and 3, destructors will be unable to use module subsystems, at 
SM> least for the modules that do some shutdowns (like closing connections, 
SM> etc.). Also, due to 2, unless we have a way for an object to "hold" a 
SM> resource, they are unable to use resources. However, even if we make 
SM> destructors to be able to use these resources, who is going to shut the 
SM> resources down afterwards?

We have such things. ext/sqlite and ext/mysqli encasulate database resources
in overloaded objects so as i wrote already we simply need a third shutdown
phase and everything is fine and it seems you came to the same conclusion :-)

SM> Now, one of the ways would be to make two "shutdown points" - "early" and 
SM> "late", shutting down before and after objects shutdown. Now, "late 
SM> shutdown" modules would be unable to use any of the PHP variables while 
SM> "early" shutdown modules would be unable to clean up any resources.

I like the second idea better because it is cleaner and more powerful.

SM> Maybe we can have two shutdown callbacks - "finalize", where the module 
SM> should do all final tasks, such as commit transactions, flush files, write 
SM> down sessions, clean up hashtables, etc. - and "shutdown", where the 
SM> module should shut down subsystems, such as close connections, destroy 
SM> resources and hashes, etc. It should be checked that all modules indeed 
SM> fit this scheme, however.

This seems like 'the' open question. But ATM i cannot think of any module not
fitting into this scheme. Especially since the modules could ensure their
order themselves where really necessary by hacking into other modules shutdown
callbacks.


Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]


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

Reply via email to