mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 08:14:45 +02:00
HTTPClient: Fix socket leak on connect failure
This commit is contained in:
@@ -127,6 +127,14 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
|
||||
ERROR_LOG(IO, "Bad socket");
|
||||
continue;
|
||||
}
|
||||
// Windows sockets aren't limited by socket number, just by count, so checking FD_SETSIZE there is wrong.
|
||||
#if !PPSSPP_PLATFORM(WINDOWS)
|
||||
if (sock >= FD_SETSIZE) {
|
||||
ERROR_LOG(IO, "Socket doesn't fit in FD_SET: %d We probably have a leak.", sock);
|
||||
closesocket(sock);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
fd_util::SetNonBlocking(sock, true);
|
||||
|
||||
// Start trying to connect (async with timeout.)
|
||||
@@ -194,6 +202,11 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
|
||||
|
||||
// Great, now we're good to go.
|
||||
return true;
|
||||
} else {
|
||||
// Fail. Close all the sockets.
|
||||
for (int sock : sockets) {
|
||||
closesocket(sock);
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelConnect && *cancelConnect) {
|
||||
|
||||
Reference in New Issue
Block a user