From 40cc9d9d7a507119981566c31852cbe6018d640b Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sun, 10 Oct 1999 13:30:03 +0000 Subject: [PATCH] This should fix the deadlock --- TSRM/TSRM.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index c6a67266a3..87fb25f37c 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -176,15 +176,17 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_ { int i; - if (tsrm_new_thread_begin_handler) { - tsrm_new_thread_begin_handler(thread_id); - } - (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry)); (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count); (*thread_resources_ptr)->count = id_count; (*thread_resources_ptr)->thread_id = thread_id; (*thread_resources_ptr)->next = NULL; + + tsrm_mutex_unlock(tsmm_mutex); + + if (tsrm_new_thread_begin_handler) { + tsrm_new_thread_begin_handler(thread_id); + } for (i=0; istorage[i] = (void *) malloc(resource_types_table[i].size); if (resource_types_table[i].ctor) { @@ -213,7 +215,8 @@ void *ts_resource(ts_rsrc_id id) if (!thread_resources) { allocate_new_resource(&tsrm_tls_table[hash_value], thread_id); - thread_resources = tsrm_tls_table[hash_value]; + return ts_resource(id); + /* thread_resources = tsrm_tls_table[hash_value]; */ } else { do { if (thread_resources->thread_id == thread_id) { @@ -223,8 +226,11 @@ void *ts_resource(ts_rsrc_id id) thread_resources = thread_resources->next; } else { allocate_new_resource(&thread_resources->next, thread_id); - thread_resources = thread_resources->next; - break; + return ts_resource(id); + /* + * thread_resources = thread_resources->next; + * break; + */ } } while (thread_resources); } -- 2.40.0