]> granicus.if.org Git - php/commitdiff
Fixed bug #35988 (Unknown persistent list entry type in module shutdown)
authorDmitry Stogov <dmitry@php.net>
Tue, 14 Mar 2006 15:16:27 +0000 (15:16 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 14 Mar 2006 15:16:27 +0000 (15:16 +0000)
TSRM/TSRM.c
TSRM/TSRM.h
main/main.c

index c07d6066846f77d164ebaf1132a6aedd1dd18b0b..8acf0698a9685490403935941083ec2c420aba3e 100644 (file)
@@ -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)
 {
index 056089aa948a82af28caba1e96bd8a2f43174f95..2eecd52b6e4f9021d3c5368c3cc5964198956609 100644 (file)
@@ -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);
 
index 55f018efa99e1c5284e178c3722aabc27fe50a1c..e91ec291b546380ef85384b9f01235c9f71fab27 100644 (file)
@@ -1699,6 +1699,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();