Get GDAX working.
[c11tester.git] / threads.cc
index 8d078b51bbfa1a8c0b4bc03b3176afa85f3a4d97..0da9282aa942bd2966bf939d6409636fa99049e5 100644 (file)
@@ -13,6 +13,7 @@
 /* global "model" object */
 #include "model.h"
 #include "execution.h"
+#include "schedule.h"
 
 #ifdef TLS
 #include <dlfcn.h>
@@ -319,10 +320,15 @@ void Thread::complete()
        if (stack)
                stack_free(stack);
 #ifdef TLS
-       if (this != model->getInitThread()) {
+       if (this != model->getInitThread() && !model->getParams()->threadsnocleanup) {
                modellock = 1;
+               ASSERT(thread_current()==NULL);
+               Thread * curr_thread = model->getScheduler()->get_current_thread();
+               //Make any current_thread calls work in code to free
+               model->getScheduler()->set_current_thread(this);
                real_pthread_mutex_unlock(&mutex2);
                real_pthread_join(thread, NULL);
+               model->getScheduler()->set_current_thread(curr_thread);
                modellock = 0;
        }
 #endif