From 72fdaec8100561edf64d51ff56f9fef430e598e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Sun, 5 Jul 1998 15:48:58 +0200
Subject: [PATCH] Fixed bug in THREADS_DISALLOW when threads are disabled.
 Waited on the wrong signal.

Rev: src/threads.h:1.44
---
 src/threads.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/threads.h b/src/threads.h
index 61f1ac3b14..982adb1397 100644
--- a/src/threads.h
+++ b/src/threads.h
@@ -1,5 +1,5 @@
 /*
- * $Id: threads.h,v 1.43 1998/06/25 14:50:25 grubba Exp $
+ * $Id: threads.h,v 1.44 1998/07/05 13:48:58 grubba Exp $
  */
 #ifndef THREADS_H
 #define THREADS_H
@@ -357,7 +357,7 @@ struct thread_state {
      struct thread_state *_tmp=(struct thread_state *)thread_id->storage; \
      if(num_threads > 1 && !threads_disabled) { \
        SWAP_OUT_THREAD(_tmp); \
-       THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x (#%d)\n", \
+       THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x(#%d)\n", \
 			__FILE__, __LINE__, \
 			(unsigned int)_tmp->thread_id, live_threads)); \
        mt_unlock(& interpreter_lock); \
@@ -368,12 +368,12 @@ struct thread_state {
      REVEAL_GLOBAL_VARIABLES(); \
      if(_tmp->swapped) { \
        mt_lock(& interpreter_lock); \
-       THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d... t:%08x (#%d)\n", \
+       THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d t:%08x(#%d)\n", \
 			__FILE__, __LINE__, \
                         (unsigned int)_tmp->thread_id, live_threads)); \
        while (threads_disabled) { \
          THREADS_FPRINTF((stderr, "THREADS_DISALLOW(): Threads disabled\n")); \
-         co_wait(&live_threads_change, &interpreter_lock); \
+         co_wait(&threads_disabled_change, &interpreter_lock); \
        } \
        SWAP_IN_THREAD(_tmp);\
      } \
@@ -384,7 +384,7 @@ struct thread_state {
      if(num_threads > 1 && !threads_disabled) { \
        SWAP_OUT_THREAD(_tmp_uid); \
        live_threads++; \
-       THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x (#%d)\n", \
+       THREADS_FPRINTF((stderr, "THREADS_ALLOW_UID() %s:%d t:%08x(#%d)\n", \
 			__FILE__, __LINE__, \
 			(unsigned int)_tmp_uid->thread_id, live_threads)); \
        mt_unlock(& interpreter_lock); \
@@ -396,12 +396,12 @@ struct thread_state {
      if(_tmp_uid->swapped) { \
        mt_lock(& interpreter_lock); \
        live_threads--; \
-       THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d... t:%08x (#%d)\n", \
+       THREADS_FPRINTF((stderr, "THREADS_DISALLOW_UID() %s:%d t:%08x(#%d)\n", \
 			__FILE__, __LINE__, \
                         (unsigned int)_tmp_uid->thread_id, live_threads)); \
+       co_broadcast(&live_threads_change); \
        while (threads_disabled) { \
-         THREADS_FPRINTF((stderr, "THREADS_DISALLOW(): Threads disabled\n")); \
-         co_signal(&live_threads_change); \
+         THREADS_FPRINTF((stderr, "THREADS_DISALLOW_UID(): Wait...\n")); \
          co_wait(&threads_disabled_change, &interpreter_lock); \
        } \
        SWAP_IN_THREAD(_tmp_uid);\
-- 
GitLab