Record active sockets in wxWebSessionCURL

If a wxWebRequestCURL object is canceled or deleted before its transfer
is complete, we need to manually close its active socket.  Record each
transfer’s active socket in wxWebSessionCURL::SocketCallback so can use
it if needed.

Previously, this was done using curl_easy_getinfo, but this required
some compile time and run time checks and could fail in some specific
cases. Recording the socket ourselves significantly simplifies the code
and should always work.
This commit is contained in:
New Pagodi
2021-02-08 12:32:32 -06:00
parent 7105499561
commit ab63e73920
2 changed files with 42 additions and 74 deletions

View File

@@ -168,12 +168,17 @@ private:
void ProcessSocketPollerResult(wxThreadEvent&);
void CheckForCompletedTransfers();
void FailRequest(CURL*, const wxString&);
void StopTransfer(CURL*);
void StopActiveTransfer(CURL*);
void RemoveActiveSocket(CURL*);
WX_DECLARE_HASH_MAP(CURL*, wxWebRequestCURL*, wxPointerHash, \
wxPointerEqual, TransferSet);
WX_DECLARE_HASH_MAP(CURL*, curl_socket_t, wxPointerHash, \
wxPointerEqual, CurlSocketMap);
TransferSet m_activeTransfers;
CurlSocketMap m_activeSockets;
SocketPoller* m_socketPoller;
wxTimer m_timeoutTimer;