-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
We currently use ZEND_HASH_REVERSE_FOREACH to free persistent clients. We should be able to simplify this code to just use zend_hash_graceful_reverse_destroy, provided we also designate an element destructor.
Quoting the PHP 5 HashTable docs (since PHP 7+ version is unwritten):
The zend_hash_destroy() function will invoke the destructor function on all buckets and free them. While this function runs the hashtable is in an inconsistent state and can not be used. This is usually okay, but in some rare cases (especially if the destructor function can call userland code) it may be necessary that the hashtable stays usable during the destruction process. In this case the zend_hash_graceful_destroy() and zend_hash_graceful_reverse_destroy() functions can be used. The former function will destroy the buckets in order of insertion, the latter in reverse order.
There is no zend_hash_reverse_destroy, so we should use zend_hash_graceful_reverse_destroy. Coincidentally, this is the same function PHP uses to destroy loaded modules (which may depend on previously loaded modules).
- is related to
-
PHPC-1722 Persistent clients and their HashTable should be destroyed in GSHUTDOWN
- Closed