[m-rev.] diff: thread resource leaks

Peter Wang novalazy at gmail.com
Tue Aug 2 14:20:19 AEST 2011


Branches: main, 11.07

library/thread.m:
	Really create threads in the detached state so that resources will be
	automatically freed when threads terminate.  I had attempted this
	previously but forgot to update a single line so that the change had no
	effect.

diff --git a/library/thread.m b/library/thread.m
index aba7122..32fc569 100644
--- a/library/thread.m
+++ b/library/thread.m
@@ -359,7 +359,7 @@ INIT mercury_sys_init_thread_modules
 
     pthread_attr_init(&attrs);
     pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
-    if (pthread_create(&thread, MR_THREAD_ATTR, ML_thread_wrapper, args)) {
+    if (pthread_create(&thread, &attrs, ML_thread_wrapper, args)) {
         MR_fatal_error(""Unable to create thread."");
     }
     pthread_attr_destroy(&attrs);

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list