fix wait/notify regression introduced in last commit

This commit is contained in:
Joel Dice 2008-01-16 14:58:27 -07:00
parent 6ba7852a62
commit bb85f5c94d
2 changed files with 15 additions and 8 deletions

View File

@ -275,6 +275,7 @@ class MySystem: public System {
if (owner_ == t) {
bool interrupted;
bool notified;
unsigned depth;
{ ACQUIRE(t->mutex);
@ -303,11 +304,9 @@ class MySystem: public System {
int rv UNUSED = pthread_cond_wait(&(t->condition), &(t->mutex));
expect(s, rv == 0 or rv == EINTR);
}
if ((t->flags & Notified) == 0) {
remove(t);
}
notified = ((t->flags & Notified) == Notified);
t->flags = 0;
t->next = 0;
@ -320,6 +319,11 @@ class MySystem: public System {
}
pthread_mutex_lock(&mutex);
if (not notified) {
remove(t);
}
owner_ = t;
this->depth = depth;

View File

@ -241,6 +241,7 @@ class MySystem: public System {
if (owner_ == t) {
bool interrupted;
bool notified;
unsigned depth;
int r UNUSED;
@ -273,11 +274,9 @@ class MySystem: public System {
r = WaitForSingleObject(t->mutex, INFINITE);
assert(s, r == WAIT_OBJECT_0);
if ((t->flags & Notified) == 0) {
remove(t);
}
notified = ((t->flags & Notified) == Notified);
t->flags = 0;
t->next = 0;
@ -292,6 +291,10 @@ class MySystem: public System {
r = WaitForSingleObject(mutex, INFINITE);
assert(s, r == WAIT_OBJECT_0);
if (not notified) {
remove(t);
}
owner_ = t;
this->depth = depth;