Browse Source

More race conditions (bug #131)

Bart van Strien 14 years ago
parent
commit
ece02577a5
2 changed files with 7 additions and 2 deletions
  1. 1 0
      src/modules/thread/sdl/Thread.cpp
  2. 6 2
      src/modules/thread/sdl/wrap_Thread.cpp

+ 1 - 0
src/modules/thread/sdl/Thread.cpp

@@ -270,6 +270,7 @@ namespace sdl
 			SDL_CondWait(cond, mutex);
 			v = comm->getValue(name);
 		}
+		v->retain();
 		unlock();
 		return v;
 	}

+ 6 - 2
src/modules/thread/sdl/wrap_Thread.cpp

@@ -109,7 +109,9 @@ namespace sdl
 				lua_pushnil(L);
 				break;
 		}
+		t->lock();
 		v->release();
+		t->unlock();
 		return 1;
 	}
 
@@ -123,7 +125,6 @@ namespace sdl
 			lua_pushnil(L);
 			return 1;
 		}
-		v->retain();
 		t->clear(name);
 		switch(v->type)
 		{
@@ -151,7 +152,9 @@ namespace sdl
 				lua_pushnil(L);
 				break;
 		}
+		t->lock();
 		v->release();
+		t->unlock();
 		return 1;
 	}
 
@@ -165,7 +168,6 @@ namespace sdl
 			lua_pushnil(L);
 			return 1;
 		}
-		v->retain();
 		switch(v->type)
 		{
 			case BOOLEAN:
@@ -192,7 +194,9 @@ namespace sdl
 				lua_pushnil(L);
 				break;
 		}
+		t->lock();
 		v->release();
+		t->unlock();
 		return 1;
 	}