Fix race condition when setting the request state to active

Call SetState(State_Active) before signalling the worker thread, as
otherwise it would be possible for it to wake up and set its state to
something else before it was reset to "active" from the main thread.

This fixed another TSAN error.
This commit is contained in:
Vadim Zeitlin
2021-01-11 01:15:28 +01:00
parent fd1d396406
commit de93f8be5b

View File

@@ -230,16 +230,13 @@ bool wxWebRequestCURL::StartRequest()
{
m_bytesSent = 0;
if ( m_sessionImpl.StartRequest(*this) )
{
SetState(wxWebRequest::State_Active);
return true;
}
else
if ( !m_sessionImpl.StartRequest(*this) )
{
SetState(wxWebRequest::State_Failed);
return false;
}
return true;
}
void wxWebRequestCURL::Cancel()
@@ -517,6 +514,8 @@ bool wxWebSessionCURL::StartRequest(wxWebRequestCURL & request)
return false;
}
request.SetState(wxWebRequest::State_Active);
// Signal the worker thread to resume work
wxMutexLocker lock(m_mutex);
m_condition.Signal();