зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f73cd738c1fe (bug 1038854) a=backout
This commit is contained in:
Родитель
f5c8104eac
Коммит
c60b44a7b1
|
@ -140,21 +140,7 @@ struct thread_info : public mozilla::LinkedListElement<thread_info> {
|
|||
|
||||
TLSInfoList tlsInfo;
|
||||
|
||||
/**
|
||||
* We must ensure that the recreated thread has entered pthread_cond_wait() or
|
||||
* similar functions before proceeding to recreate the next one. Otherwise, if
|
||||
* the next thread depends on the same mutex, it may be used in an incorrect
|
||||
* state. To do this, the main thread must unconditionally acquire the mutex.
|
||||
* The mutex is unconditionally released when the recreated thread enters
|
||||
* pthread_cond_wait(). The recreated thread may have locked the mutex itself
|
||||
* (if the pthread_mutex_trylock succeeded) or another thread may have already
|
||||
* held the lock. If the recreated thread did lock the mutex we must balance
|
||||
* that with another unlock on the main thread, which is signaled by
|
||||
* condMutexNeedsBalancing.
|
||||
*/
|
||||
pthread_mutex_t *condMutex;
|
||||
bool condMutexNeedsBalancing;
|
||||
|
||||
pthread_mutex_t *reacquireMutex;
|
||||
void *stk;
|
||||
|
||||
pid_t origNativeThreadID;
|
||||
|
@ -515,8 +501,7 @@ thread_info_new(void) {
|
|||
tinfo->recrArg = nullptr;
|
||||
tinfo->recreatedThreadID = 0;
|
||||
tinfo->recreatedNativeThreadID = 0;
|
||||
tinfo->condMutex = nullptr;
|
||||
tinfo->condMutexNeedsBalancing = false;
|
||||
tinfo->reacquireMutex = nullptr;
|
||||
tinfo->stk = MozTaggedAnonymousMmap(nullptr,
|
||||
NUWA_STACK_SIZE + getPageSize(),
|
||||
PROT_READ | PROT_WRITE,
|
||||
|
@ -1031,16 +1016,13 @@ __wrap_pthread_cond_wait(pthread_cond_t *cond,
|
|||
return rv;
|
||||
}
|
||||
if (recreated && mtx) {
|
||||
if (!freezePoint1) {
|
||||
tinfo->condMutex = mtx;
|
||||
if (!freezePoint1 && pthread_mutex_trylock(mtx)) {
|
||||
// The thread was frozen in pthread_cond_wait() after releasing mtx in the
|
||||
// Nuwa process. In recreating this thread, We failed to reacquire mtx
|
||||
// with the pthread_mutex_trylock() call, that is, mtx was acquired by
|
||||
// another thread. Because of this, we need the main thread's help to
|
||||
// reacquire mtx so that it will be in a valid state.
|
||||
if (!pthread_mutex_trylock(mtx)) {
|
||||
tinfo->condMutexNeedsBalancing = true;
|
||||
}
|
||||
tinfo->reacquireMutex = mtx;
|
||||
}
|
||||
RECREATE_CONTINUE();
|
||||
RECREATE_PASS_VIP();
|
||||
|
@ -1070,11 +1052,8 @@ __wrap_pthread_cond_timedwait(pthread_cond_t *cond,
|
|||
return rv;
|
||||
}
|
||||
if (recreated && mtx) {
|
||||
if (!freezePoint1) {
|
||||
tinfo->condMutex = mtx;
|
||||
if (!pthread_mutex_trylock(mtx)) {
|
||||
tinfo->condMutexNeedsBalancing = true;
|
||||
}
|
||||
if (!freezePoint1 && pthread_mutex_trylock(mtx)) {
|
||||
tinfo->reacquireMutex = mtx;
|
||||
}
|
||||
RECREATE_CONTINUE();
|
||||
RECREATE_PASS_VIP();
|
||||
|
@ -1108,11 +1087,8 @@ __wrap___pthread_cond_timedwait(pthread_cond_t *cond,
|
|||
return rv;
|
||||
}
|
||||
if (recreated && mtx) {
|
||||
if (!freezePoint1) {
|
||||
tinfo->condMutex = mtx;
|
||||
if (!pthread_mutex_trylock(mtx)) {
|
||||
tinfo->condMutexNeedsBalancing = true;
|
||||
}
|
||||
if (!freezePoint1 && pthread_mutex_trylock(mtx)) {
|
||||
tinfo->reacquireMutex = mtx;
|
||||
}
|
||||
RECREATE_CONTINUE();
|
||||
RECREATE_PASS_VIP();
|
||||
|
@ -1427,12 +1403,8 @@ RecreateThreads() {
|
|||
RECREATE_BEFORE(tinfo);
|
||||
thread_recreate(tinfo);
|
||||
RECREATE_WAIT();
|
||||
if (tinfo->condMutex) {
|
||||
// Synchronize with the recreated thread in pthread_cond_wait().
|
||||
REAL(pthread_mutex_lock)(tinfo->condMutex);
|
||||
if (tinfo->condMutexNeedsBalancing) {
|
||||
pthread_mutex_unlock(tinfo->condMutex);
|
||||
}
|
||||
if (tinfo->reacquireMutex) {
|
||||
REAL(pthread_mutex_lock)(tinfo->reacquireMutex);
|
||||
}
|
||||
} else if(!(tinfo->flags & TINFO_FLAG_NUWA_SKIP)) {
|
||||
// An unmarked thread is found other than the main thread.
|
||||
|
|
Загрузка…
Ссылка в новой задаче