summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2006-03-14 15:16:07 +0000
committerDmitry Stogov <dmitry@php.net>2006-03-14 15:16:07 +0000
commit98bacb0e219eeaa865c09f17f4c07b50a848aa26 (patch)
tree221a58e676211a77d3175a3002f4a88e7cef5f1d
parentef3d879315e816862905a1a48e0e3452b9173443 (diff)
downloadphp-git-98bacb0e219eeaa865c09f17f4c07b50a848aa26.tar.gz
Fixed bug #35988 (Unknown persistent list entry type in module shutdown)
-rw-r--r--NEWS2
-rw-r--r--TSRM/TSRM.c46
-rw-r--r--TSRM/TSRM.h3
-rw-r--r--main/main.c4
4 files changed, 55 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d869deecfb..f25ac55ad9 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ PHP NEWS
- Fixed bug #36697 (Transparency is lost when using imagecreatetruecolor).
(Pierre)
- Fixed bug #36568 (memory_limit setting on win32 has no effect). (Dmitry)
+- Fixed bug #35988 (Unknown persistent list entry type in module shutdown).
+ (Dmitry)
09 Mar 2006, PHP 5.1.3RC1
- Updated PCRE to version 6.6. (Andrei)
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index c07d606684..8acf0698a9 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -480,6 +480,52 @@ void ts_free_thread(void)
}
+/* frees all resources allocated for all threads except current */
+void ts_free_worker_threads(void)
+{
+ tsrm_tls_entry *thread_resources;
+ int i;
+ THREAD_T thread_id = tsrm_thread_id();
+ int hash_value;
+ tsrm_tls_entry *last=NULL;
+
+ tsrm_mutex_lock(tsmm_mutex);
+ hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
+ thread_resources = tsrm_tls_table[hash_value];
+
+ while (thread_resources) {
+ if (thread_resources->thread_id != thread_id) {
+ for (i=0; i<thread_resources->count; i++) {
+ if (resource_types_table[i].dtor) {
+ resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ }
+ }
+ for (i=0; i<thread_resources->count; i++) {
+ free(thread_resources->storage[i]);
+ }
+ free(thread_resources->storage);
+ if (last) {
+ last->next = thread_resources->next;
+ } else {
+ tsrm_tls_table[hash_value] = thread_resources->next;
+ }
+ free(thread_resources);
+ if (last) {
+ thread_resources = last->next;
+ } else {
+ thread_resources = tsrm_tls_table[hash_value];
+ }
+ } else {
+ if (thread_resources->next) {
+ last = thread_resources;
+ }
+ thread_resources = thread_resources->next;
+ }
+ }
+ tsrm_mutex_unlock(tsmm_mutex);
+}
+
+
/* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id)
{
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index 056089aa94..2eecd52b6e 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -106,6 +106,9 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
/* frees all resources allocated for the current thread */
TSRM_API void ts_free_thread(void);
+/* frees all resources allocated for all threads except current */
+void ts_free_worker_threads(void);
+
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);
diff --git a/main/main.c b/main/main.c
index 0626b5c047..3848d501fe 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1594,6 +1594,10 @@ void php_module_shutdown(TSRMLS_D)
return;
}
+#ifdef ZTS
+ ts_free_worker_threads();
+#endif
+
#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
/*close winsock */
WSACleanup();