core, yuzu: Address first part of review comments
This commit is contained in:
parent
a5cd639cb6
commit
6d41088153
9 changed files with 70 additions and 71 deletions
|
@ -31,7 +31,7 @@ AnnounceMultiplayerSession::AnnounceMultiplayerSession(Network::RoomNetwork& roo
|
|||
}
|
||||
|
||||
WebService::WebResult AnnounceMultiplayerSession::Register() {
|
||||
std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
|
||||
auto room = room_network.GetRoom().lock();
|
||||
if (!room) {
|
||||
return WebService::WebResult{WebService::WebResult::Code::LibError,
|
||||
"Network is not initialized", ""};
|
||||
|
@ -102,7 +102,7 @@ void AnnounceMultiplayerSession::UpdateBackendData(std::shared_ptr<Network::Room
|
|||
void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
|
||||
// Invokes all current bound error callbacks.
|
||||
const auto ErrorCallback = [this](WebService::WebResult result) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex);
|
||||
std::lock_guard lock(callback_mutex);
|
||||
for (auto callback : error_callbacks) {
|
||||
(*callback)(result);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
|
|||
std::future<WebService::WebResult> future;
|
||||
while (!shutdown_event.WaitUntil(update_time)) {
|
||||
update_time += announce_time_interval;
|
||||
std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
|
||||
auto room = room_network.GetRoom().lock();
|
||||
if (!room) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -381,6 +381,7 @@ void IGeneralService::GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(*ipv4);
|
||||
}
|
||||
|
||||
void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
|
||||
|
|
|
@ -352,8 +352,8 @@ std::optional<IPv4Address> GetHostIPv4Address() {
|
|||
return {};
|
||||
}
|
||||
|
||||
char ip_addr[16] = {};
|
||||
ASSERT(inet_ntop(AF_INET, &interface->ip_address, ip_addr, sizeof(ip_addr)) != nullptr);
|
||||
std::array<char, 16> ip_addr = {};
|
||||
ASSERT(inet_ntop(AF_INET, &interface->ip_address, ip_addr.data(), sizeof(ip_addr)) != nullptr);
|
||||
return TranslateIPv4(interface->ip_address);
|
||||
}
|
||||
|
||||
|
@ -402,9 +402,9 @@ Socket::Socket(Socket&& rhs) noexcept {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
Errno Socket::SetSockOpt(SOCKET _fd, int option, T value) {
|
||||
Errno Socket::SetSockOpt(SOCKET fd_, int option, T value) {
|
||||
const int result =
|
||||
setsockopt(_fd, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
|
||||
setsockopt(fd_, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
|
||||
if (result != SOCKET_ERROR) {
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
|
|
@ -30,19 +30,19 @@ void ProxySocket::HandleProxyPacket(const ProxyPacket& packet) {
|
|||
closed) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(packets_mutex);
|
||||
std::lock_guard guard(packets_mutex);
|
||||
received_packets.push(packet);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Errno ProxySocket::SetSockOpt(SOCKET _fd, int option, T value) {
|
||||
Errno ProxySocket::SetSockOpt(SOCKET fd_, int option, T value) {
|
||||
socket_options[option] = reinterpret_cast<const char*>(&value);
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::Initialize(Domain domain, Type type, Protocol socket_protocol) {
|
||||
protocol = socket_protocol;
|
||||
socket_options[0x1008] = reinterpret_cast<const char*>(&type);
|
||||
SetSockOpt(fd, SO_TYPE, type);
|
||||
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::vector<u8>& message,
|
|||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(packets_mutex);
|
||||
std::lock_guard guard(packets_mutex);
|
||||
if (received_packets.size() > 0) {
|
||||
return ReceivePacket(flags, message, addr, message.size());
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::vector<u8>& message,
|
|||
return {-1, Errno::AGAIN};
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(packets_mutex);
|
||||
std::lock_guard guard(packets_mutex);
|
||||
if (received_packets.size() > 0) {
|
||||
return ReceivePacket(flags, message, addr, message.size());
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Network {
|
|||
|
||||
class ProxySocket : public SocketBase {
|
||||
public:
|
||||
ProxySocket(RoomNetwork& room_network_) noexcept;
|
||||
explicit ProxySocket(RoomNetwork& room_network_) noexcept;
|
||||
~ProxySocket() override;
|
||||
|
||||
ProxySocket(const ProxySocket&) = delete;
|
||||
|
@ -82,6 +82,7 @@ public:
|
|||
|
||||
bool IsOpened() const override;
|
||||
|
||||
private:
|
||||
bool broadcast = false;
|
||||
bool closed = false;
|
||||
u32 send_timeout = 0;
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
std::unique_ptr<SocketBase> socket;
|
||||
SockAddrIn sockaddr_in;
|
||||
};
|
||||
virtual ~SocketBase() {}
|
||||
virtual ~SocketBase() = default;
|
||||
|
||||
virtual SocketBase& operator=(const SocketBase&) = delete;
|
||||
|
||||
|
@ -89,11 +89,7 @@ public:
|
|||
|
||||
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
|
||||
|
||||
#if defined(_WIN32)
|
||||
SOCKET fd = INVALID_SOCKET;
|
||||
#elif YUZU_UNIX
|
||||
int fd = -1;
|
||||
#endif
|
||||
};
|
||||
|
||||
class Socket : public SocketBase {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue