Fix Cancel() semantics under MSW and other improvements to it

Under MSW, don't set the state to State_Cancelled as soon as Cancel()
was called, as the request was still used from the other threads
afterwards, resulting in race conditions and crashes.

Fix this by just removing the SetState(State_Cancelled) call from the
main thread, as it was redundant anyhow. This also makes the behaviour
correspond to the documentation, which indicates that Cancel() works
asynchronously.

Also ensure, for all backends, that we actually cancel the request only
once, even if public Cancel() is called multiple times. This required
renaming the existing wxWebRequestImpl::Cancel() to DoCancel().
This commit is contained in:
Vadim Zeitlin
2021-01-16 13:49:22 +01:00
parent b428e531ee
commit 508a4f6ca8
9 changed files with 49 additions and 21 deletions

View File

@@ -50,8 +50,6 @@ public:
void Start() wxOVERRIDE;
void Cancel() wxOVERRIDE;
wxWebResponseImplPtr GetResponse() const wxOVERRIDE
{ return m_response; }
@@ -79,6 +77,8 @@ public:
size_t CURLOnRead(char* buffer, size_t size);
private:
void DoCancel() wxOVERRIDE;
wxWebSessionCURL& m_sessionImpl;
CURL* m_handle;