cvs: TSRM / TSRM.c

From: Date: Wed, 12 May 2004 10:30:47 +0000
Subject: cvs: TSRM / TSRM.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2632@lists.php.net to get a copy of this message
helly Wed May 12 06:30:47 2004 EDT Modified files: /TSRM TSRM.c Log: - Implement ts_free_id() http://cvs.php.net/diff.php/TSRM/TSRM.c?r1=1.56&r2=1.57&ty=u Index: TSRM/TSRM.c diff -u TSRM/TSRM.c:1.56 TSRM/TSRM.c:1.57 --- TSRM/TSRM.c:1.56 Tue Mar 30 11:56:01 2004 +++ TSRM/TSRM.c Wed May 12 06:30:46 2004 @@ -158,18 +158,12 @@ 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 @@ /* 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)); }

« previous php.zend-engine.cvs (#2632) next »