summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2004-05-12 10:30:46 +0000
committerMarcus Boerger <helly@php.net>2004-05-12 10:30:46 +0000
commit8e52e04c30c631c9d1a231da051f6b3dd0c22b79 (patch)
treeae052ae9f0719b2f14cd8860530133501441375f /TSRM
parent40a9fd5f766d774fb341690580db75a2126dfd2f (diff)
downloadphp-git-8e52e04c30c631c9d1a231da051f6b3dd0c22b79.tar.gz
- Implement ts_free_id()
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/TSRM.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index b3e5c9b587..e075ce8551 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -158,18 +158,12 @@ TSRM_API void tsrm_shutdown(void)
next_p = p->next;
for (j=0; j<p->count; j++) {
- /*
- Disabled calling dtors on tsrm_shutdown - calling dtors
- in tsrm_shutdown makes modules registering TSRM ids
- to crash, if they have dtors, since the module is unloaded
- before tsrm_shutdown is called. Can be re-enabled after
- tsrm_free_id is implemented.
-
- if (resource_types_table && resource_types_table[j].dtor) {
- resource_types_table[j].dtor(p->storage[j], &p->storage);
+ if (p->storage[j]) {
+ if (resource_types_table && resource_types_table[j].dtor) {
+ resource_types_table[j].dtor(p->storage[j], &p->storage);
+ }
+ free(p->storage[j]);
}
- */
- free(p->storage[j]);
}
free(p->storage);
free(p);
@@ -428,6 +422,33 @@ void ts_free_thread(void)
/* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id)
{
+ int i;
+ int j = TSRM_UNSHUFFLE_RSRC_ID(id);
+
+ tsrm_mutex_lock(tsmm_mutex);
+
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Freeing resource id %d", id));
+
+ if (tsrm_tls_table) {
+ for (i=0; i<tsrm_tls_table_size; i++) {
+ tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
+
+ while (p) {
+ if (p->count > j && p->storage[j]) {
+ if (resource_types_table && resource_types_table[j].dtor) {
+ resource_types_table[j].dtor(p->storage[j], &p->storage);
+ }
+ free(p->storage[j]);
+ p->storage[j] = NULL;
+ }
+ p = p->next;
+ }
+ }
+ }
+
+ tsrm_mutex_unlock(tsmm_mutex);
+
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully freed resource id %d", id));
}