Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLocalIp: Keep looking if we see 127.0.0.1 #19926

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Common/Net/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {

selectResult = select(maxfd, nullptr, &fds, nullptr, &tv);
if (cancelConnect && *cancelConnect) {
WARN_LOG(Log::HTTP, "connect: cancelled (1)");
WARN_LOG(Log::HTTP, "connect: cancelled (1): %s:%d", host_.c_str(), port_);
break;
}
}
Expand All @@ -183,7 +183,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
}

if (cancelConnect && *cancelConnect) {
WARN_LOG(Log::HTTP, "connect: cancelled (2)");
WARN_LOG(Log::HTTP, "connect: cancelled (2): %s:%d", host_.c_str(), port_);
break;
}

Expand Down
8 changes: 6 additions & 2 deletions Core/HLE/proAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ int getLocalIp(sockaddr_in* SocketAddress) {

// Fallback if not connected to AdhocServer
// getifaddrs first appeared in glibc 2.3, On Android officially supported since __ANDROID_API__ >= 24
#if defined(_IFADDRS_H_) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__ANDROID_API__ >= 24)
#if (defined(_IFADDRS_H_) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__ANDROID_API__ >= 24))
struct ifaddrs* ifAddrStruct = NULL;
struct ifaddrs* ifa = NULL;

Expand All @@ -1808,7 +1808,11 @@ int getLocalIp(sockaddr_in* SocketAddress) {
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
// is a valid IP4 Address
SocketAddress->sin_addr = ((struct sockaddr_in*)ifa->ifa_addr)->sin_addr;
break;
u32 addr = ((struct sockaddr_in*)ifa->ifa_addr)->sin_addr.s_addr;
if (addr != 0x0100007f) { // 127.0.0.1
// Found a plausible one
break;
}
}
}
freeifaddrs(ifAddrStruct);
Expand Down
12 changes: 8 additions & 4 deletions Core/RetroAchievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,16 +746,20 @@ void UpdateSettings() {

bool Shutdown() {
g_activeChallenges.clear();
if (g_rcClient) {
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
rc_client_unload_raintegration(g_rcClient);
rc_client_unload_raintegration(g_rcClient);
#endif
rc_client_destroy(g_rcClient);
g_rcClient = nullptr;
INFO_LOG(Log::Achievements, "Achievements shut down.");
rc_client_destroy(g_rcClient);
g_rcClient = nullptr;
INFO_LOG(Log::Achievements, "Achievements shut down.");
}
return true;
}

void ResetRuntime() {
if (!g_rcClient)
return;
INFO_LOG(Log::Achievements, "Resetting rcheevos state...");
rc_client_reset(g_rcClient);
g_activeChallenges.clear();
Expand Down
Loading