git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55521
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
HANDLE m_mutex;
unsigned long m_owningThread;
HANDLE m_mutex;
unsigned long m_owningThread;
wxMutexType m_type;
DECLARE_NO_COPY_CLASS(wxMutexInternal)
wxMutexType m_type;
DECLARE_NO_COPY_CLASS(wxMutexInternal)
m_type = mutexType;
m_owningThread = 0;
m_type = mutexType;
m_owningThread = 0;
if (m_type == wxMUTEX_DEFAULT)
{
// Don't allow recursive
if (m_type == wxMUTEX_DEFAULT)
{
// Don't allow recursive
+ if (m_owningThread != 0)
{
if (m_owningThread == wxThread::GetCurrentId())
return wxMUTEX_DEAD_LOCK;
{
if (m_owningThread == wxThread::GetCurrentId())
return wxMUTEX_DEAD_LOCK;
if (m_type == wxMUTEX_DEFAULT)
{
// required for checking recursiveness
if (m_type == wxMUTEX_DEFAULT)
{
// required for checking recursiveness
m_owningThread = wxThread::GetCurrentId();
}
m_owningThread = wxThread::GetCurrentId();
}
wxMutexError wxMutexInternal::Unlock()
{
wxMutexError wxMutexInternal::Unlock()
{
+ // required for checking recursiveness
+ m_owningThread = 0;
+
if ( !::ReleaseMutex(m_mutex) )
{
wxLogLastError(_T("ReleaseMutex()"));
return wxMUTEX_MISC_ERROR;
}
if ( !::ReleaseMutex(m_mutex) )
{
wxLogLastError(_T("ReleaseMutex()"));
return wxMUTEX_MISC_ERROR;
}
-
- // required for checking recursiveness
- m_isLocked = false;
return wxMUTEX_NO_ERROR;
}
return wxMUTEX_NO_ERROR;
}
private:
pthread_mutex_t m_mutex;
bool m_isOk;
private:
pthread_mutex_t m_mutex;
bool m_isOk;
+ wxMutexType m_type;
+ unsigned long m_owningThread;
// wxConditionInternal uses our m_mutex
friend class wxConditionInternal;
// wxConditionInternal uses our m_mutex
friend class wxConditionInternal;
wxMutexInternal::wxMutexInternal(wxMutexType mutexType)
{
wxMutexInternal::wxMutexInternal(wxMutexType mutexType)
{
+ m_type = mutexType;
+ m_owningThread = 0;
+
int err;
switch ( mutexType )
{
int err;
switch ( mutexType )
{
wxMutexError wxMutexInternal::Lock()
{
wxMutexError wxMutexInternal::Lock()
{
+ if ((m_type == wxMUTEX_DEFAULT) && (m_owningThread != 0))
+ {
+ if (m_owningThread == wxThread::GetCurrentId())
+ return wxMUTEX_DEAD_LOCK;
+ }
+
return HandleLockResult(pthread_mutex_lock(&m_mutex));
}
return HandleLockResult(pthread_mutex_lock(&m_mutex));
}
wxMutexError wxMutexInternal::HandleLockResult(int err)
{
wxMutexError wxMutexInternal::HandleLockResult(int err)
{
+ // wxPrintf( "err %d\n", err );
+
switch ( err )
{
case EDEADLK:
switch ( err )
{
case EDEADLK:
return wxMUTEX_TIMEOUT;
case 0:
return wxMUTEX_TIMEOUT;
case 0:
+ if (m_type == wxMUTEX_DEFAULT)
+ m_owningThread = wxThread::GetCurrentId();
return wxMUTEX_NO_ERROR;
default:
return wxMUTEX_NO_ERROR;
default:
+ if (m_type == wxMUTEX_DEFAULT)
+ m_owningThread = wxThread::GetCurrentId();
return wxMUTEX_NO_ERROR;
default:
return wxMUTEX_NO_ERROR;
default:
wxMutexError wxMutexInternal::Unlock()
{
wxMutexError wxMutexInternal::Unlock()
{
int err = pthread_mutex_unlock(&m_mutex);
switch ( err )
{
int err = pthread_mutex_unlock(&m_mutex);
switch ( err )
{