summaryrefslogtreecommitdiff
path: root/TSRM/TSRM.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2001-04-04 17:05:10 +0000
committerAndi Gutmans <andi@php.net>2001-04-04 17:05:10 +0000
commit78861607d7a879faeb93ab61e525ad69319c8259 (patch)
tree1c9a36858f9dac640fb184dbc7f05a768b049c37 /TSRM/TSRM.c
parent9047e5c956a2de6f9232e6637007a47846ce5359 (diff)
downloadphp-git-78861607d7a879faeb93ab61e525ad69319c8259.tar.gz
- Fix race condition in ts_free_thread().
Diffstat (limited to 'TSRM/TSRM.c')
-rw-r--r--TSRM/TSRM.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index 4425036ea7..1316203fc6 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -337,6 +337,11 @@ void ts_free_thread(void)
while (thread_resources) {
if (thread_resources->thread_id == thread_id) {
+ if (last) {
+ last->next = thread_resources->next;
+ } else {
+ tsrm_tls_table[hash_value] = thread_resources->next;
+ }
tsrm_mutex_unlock(tsmm_mutex);
for (i=0; i<thread_resources->count; i++) {
@@ -347,18 +352,12 @@ void ts_free_thread(void)
for (i=0; i<thread_resources->count; i++) {
free(thread_resources->storage[i]);
}
- tsrm_mutex_lock(tsmm_mutex);
free(thread_resources->storage);
- if (last) {
- last->next = thread_resources->next;
- } else {
- tsrm_tls_table[hash_value] = thread_resources->next;
- }
#if defined(PTHREADS)
- pthread_setspecific( tls_key, 0 );
+ pthread_setspecific(tls_key, 0);
#endif
free(thread_resources);
- break;
+ return; /* Don't want to reach unlock() a second time */
}
if (thread_resources->next) {
last = thread_resources;