  
  /* frees all resources allocated for the current thread */
  void ts_free_thread(void)
-@@ -417,11 +476,7 @@
+@@ -417,11 +475,7 @@
  			} else {
  				tsrm_tls_table[hash_value] = thread_resources->next;
  			}

+
+	current = tsrm_tls_get();
+
+	new_ctx = malloc(sizeof(*new_ctx));
+	allocate_new_resource(&new_ctx, thread_id);
+	
+	/* switch back to the context that was in use prior to our creation

Index: TSRM/TSRM.c
===================================================================
RCS file: /repository/TSRM/TSRM.c,v
retrieving revision 1.61.2.3
diff -u -r1.61.2.3 TSRM.c
--- TSRM/TSRM.c	16 Jul 2005 11:50:59 -0000	1.61.2.3
+++ TSRM/TSRM.c	30 Aug 2005 17:33:51 -0000
@@ -94,12 +94,28 @@
 #if defined(PTHREADS)
 /* Thread local storage */
