Fix periodic hitching when controller paired and connected

This commit is contained in:
capitalistspz 2024-09-26 03:51:56 +01:00
parent 96f485196c
commit e66984bd41

View File

@ -5,20 +5,10 @@ namespace {
std::vector<bdaddr_t> s_address; std::vector<bdaddr_t> s_address;
std::mutex s_addressMutex; std::mutex s_addressMutex;
bool AttemptConnect(int sockFd, sockaddr_l2 const& addr) bool AttemptConnect(int& sockFd, const sockaddr_l2& addr)
{ {
for (auto i = 0; i < 3; ++i) return connect(sockFd, reinterpret_cast<const sockaddr*>(&addr),
{ sizeof(sockaddr_l2)) == 0;
if (connect(sockFd, reinterpret_cast<sockaddr const*>(&addr),
sizeof(sockaddr_l2)) == 0)
return true;
cemuLog_logDebug(LogType::Force, "Connection attempt {} failed with error {:x}: {} ", i + 1, errno,
std::strerror(errno));
if (i == 2)
break;
std::this_thread::sleep_for(std::chrono::milliseconds(300));
}
return false;
} }
bool AttemptSetNonBlock(int& sockFd) bool AttemptSetNonBlock(int& sockFd)
{ {