diff options
| author | Andi Gutmans <andi@php.net> | 2001-04-04 17:05:10 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2001-04-04 17:05:10 +0000 |
| commit | 78861607d7a879faeb93ab61e525ad69319c8259 (patch) | |
| tree | 1c9a36858f9dac640fb184dbc7f05a768b049c37 /TSRM/TSRM.c | |
| parent | 9047e5c956a2de6f9232e6637007a47846ce5359 (diff) | |
| download | php-git-78861607d7a879faeb93ab61e525ad69319c8259.tar.gz | |
- Fix race condition in ts_free_thread().
Diffstat (limited to 'TSRM/TSRM.c')
| -rw-r--r-- | TSRM/TSRM.c | 15 |
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; |
