Skip to content

Commit

Permalink
Backed out changeset 3802f86e1bd1 (bug 1364624) for shutdown hangs on…
Browse files Browse the repository at this point in the history
… reftests. a=backout
  • Loading branch information
dgluca committed Apr 25, 2018
1 parent 805e6b3 commit c65030f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions mozglue/misc/ConditionVariable_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ mozilla::detail::ConditionVariableImpl::notify_all()
void
mozilla::detail::ConditionVariableImpl::wait(MutexImpl& lock)
{
SRWLOCK* srwlock = &lock.platformData()->lock;
bool r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, INFINITE, 0);
CRITICAL_SECTION* cs = &lock.platformData()->criticalSection;
bool r = SleepConditionVariableCS(&platformData()->cv_, cs, INFINITE);
MOZ_RELEASE_ASSERT(r);
}

Expand All @@ -68,7 +68,7 @@ mozilla::detail::ConditionVariableImpl::wait_for(MutexImpl& lock,
return CVStatus::NoTimeout;
}

SRWLOCK* srwlock = &lock.platformData()->lock;
CRITICAL_SECTION* cs = &lock.platformData()->criticalSection;

// Note that DWORD is unsigned, so we have to be careful to clamp at 0. If
// rel_time is Forever, then ToMilliseconds is +inf, which evaluates as
Expand All @@ -89,7 +89,7 @@ mozilla::detail::ConditionVariableImpl::wait_for(MutexImpl& lock,
}
}

BOOL r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, msec, 0);
BOOL r = SleepConditionVariableCS(&platformData()->cv_, cs, msec);
if (r)
return CVStatus::NoTimeout;
MOZ_RELEASE_ASSERT(GetLastError() == ERROR_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion mozglue/misc/MutexPlatformData_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

struct mozilla::detail::MutexImpl::PlatformData
{
SRWLOCK lock;
CRITICAL_SECTION criticalSection;
};

#endif // MutexPlatformData_windows_h
21 changes: 18 additions & 3 deletions mozglue/misc/Mutex_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,38 @@

mozilla::detail::MutexImpl::MutexImpl()
{
InitializeSRWLock(&platformData()->lock);
// This number was adopted from NSPR.
const static DWORD LockSpinCount = 1500;

#if defined(RELEASE_OR_BETA)
// Vista and later automatically allocate and subsequently leak a debug info
// object for each critical section that we allocate unless we tell the
// system not to do that.
DWORD flags = CRITICAL_SECTION_NO_DEBUG_INFO;
#else
DWORD flags = 0;
#endif // defined(RELEASE_OR_BETA)

BOOL r = InitializeCriticalSectionEx(&platformData()->criticalSection,
LockSpinCount, flags);
MOZ_RELEASE_ASSERT(r);
}

mozilla::detail::MutexImpl::~MutexImpl()
{
DeleteCriticalSection(&platformData()->criticalSection);
}

void
mozilla::detail::MutexImpl::lock()
{
AcquireSRWLockExclusive(&platformData()->lock);
EnterCriticalSection(&platformData()->criticalSection);
}

void
mozilla::detail::MutexImpl::unlock()
{
ReleaseSRWLockExclusive(&platformData()->lock);
LeaveCriticalSection(&platformData()->criticalSection);
}

mozilla::detail::MutexImpl::PlatformData*
Expand Down

0 comments on commit c65030f

Please sign in to comment.