aboutsummaryrefslogtreecommitdiff
path: root/libjava/posix-threads.cc
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-09-30 10:01:04 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-09-30 11:01:04 +0100
commit304daac5d9eaa21727faa45e3e3881608d4ec2a8 (patch)
treea4e2c3a6e8a2856a0ce7f78966263082bf760310 /libjava/posix-threads.cc
parentbf3b8e42e291aeaeae178f6be1a49deebcd4e527 (diff)
downloadgcc-304daac5d9eaa21727faa45e3e3881608d4ec2a8.zip
gcc-304daac5d9eaa21727faa45e3e3881608d4ec2a8.tar.gz
gcc-304daac5d9eaa21727faa45e3e3881608d4ec2a8.tar.bz2
posix-threads.cc (_Jv_CondWait): Check to see if we are interrupted before modifying the cv's wait set.
2000-09-30 Tom Tromey <tromey@cygnus.com> * posix-threads.cc (_Jv_CondWait): Check to see if we are interrupted before modifying the cv's wait set. From-SVN: r36680
Diffstat (limited to 'libjava/posix-threads.cc')
-rw-r--r--libjava/posix-threads.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc
index e5a1668..2c7babb 100644
--- a/libjava/posix-threads.cc
+++ b/libjava/posix-threads.cc
@@ -1,6 +1,6 @@
// posix-threads.cc - interface between libjava and POSIX threads.
-/* Copyright (C) 1998, 1999 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
This file is part of libgcj.
@@ -104,6 +104,16 @@ _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
_Jv_Thread_t *current = _Jv_ThreadCurrentData ();
java::lang::Thread *current_obj = _Jv_ThreadCurrent ();
+ pthread_mutex_lock (&current->wait_mutex);
+
+ // Now that we hold the wait mutex, check if this thread has been
+ // interrupted already.
+ if (current_obj->interrupt_flag)
+ {
+ pthread_mutex_unlock (&current->wait_mutex);
+ return _JV_INTERRUPTED;
+ }
+
// Add this thread to the cv's wait set.
current->next = NULL;
@@ -119,16 +129,6 @@ _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
}
}
- pthread_mutex_lock (&current->wait_mutex);
-
- // Now that we hold the wait mutex, check if this thread has been
- // interrupted already.
- if (current_obj->interrupt_flag)
- {
- pthread_mutex_unlock (&current->wait_mutex);
- return _JV_INTERRUPTED;
- }
-
// Record the current lock depth, so it can be restored when we re-aquire it.
int count = mu->count;
@@ -154,7 +154,7 @@ _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
done_sleeping = true;
}
- // Check for an interrupt *before* unlocking the wait mutex.
+ // Check for an interrupt *before* releasing the wait mutex.
jboolean interrupted = current_obj->interrupt_flag;
pthread_mutex_unlock (&current->wait_mutex);