summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2024-01-31 17:24:30 +0100
committerGitHub <noreply@github.com>2024-01-31 17:24:30 +0100
commit12e5293c73ce9965a6f73a8861d8b84f3f4ed615 (patch)
treeda7e3189fa6e1cc912c48d5caa2bce0c11fc7915
parentMerge pull request #12869 from FernandoS27/smmu-fixes (diff)
parentinternal_network: only poll for accept on blocking sockets (diff)
downloadyuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar.gz
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar.bz2
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar.lz
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar.xz
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.tar.zst
yuzu-12e5293c73ce9965a6f73a8861d8b84f3f4ed615.zip
Diffstat (limited to '')
-rw-r--r--src/core/internal_network/network.cpp32
-rw-r--r--src/core/internal_network/sockets.h3
2 files changed, 21 insertions, 14 deletions
diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp
index a983f23ea..7785c1d16 100644
--- a/src/core/internal_network/network.cpp
+++ b/src/core/internal_network/network.cpp
@@ -693,20 +693,23 @@ std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
- std::vector<WSAPOLLFD> host_pollfds{
- WSAPOLLFD{fd, POLLIN, 0},
- WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
- };
-
- while (true) {
- const int pollres =
- WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), -1);
- if (host_pollfds[1].revents != 0) {
- // Interrupt signaled before a client could be accepted, break
- return {AcceptResult{}, Errno::AGAIN};
- }
- if (pollres > 0) {
- break;
+ const bool wait_for_accept = !is_non_blocking;
+ if (wait_for_accept) {
+ std::vector<WSAPOLLFD> host_pollfds{
+ WSAPOLLFD{fd, POLLIN, 0},
+ WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
+ };
+
+ while (true) {
+ const int pollres =
+ WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), -1);
+ if (host_pollfds[1].revents != 0) {
+ // Interrupt signaled before a client could be accepted, break
+ return {AcceptResult{}, Errno::AGAIN};
+ }
+ if (pollres > 0) {
+ break;
+ }
}
}
@@ -913,6 +916,7 @@ Errno Socket::SetRcvTimeo(u32 value) {
Errno Socket::SetNonBlock(bool enable) {
if (EnableNonBlock(fd, enable)) {
+ is_non_blocking = enable;
return Errno::SUCCESS;
}
return GetAndLogLastError();
diff --git a/src/core/internal_network/sockets.h b/src/core/internal_network/sockets.h
index 4ba51f62c..3a32dff75 100644
--- a/src/core/internal_network/sockets.h
+++ b/src/core/internal_network/sockets.h
@@ -166,6 +166,9 @@ public:
bool IsOpened() const override;
void HandleProxyPacket(const ProxyPacket& packet) override;
+
+private:
+ bool is_non_blocking = false;
};
std::pair<s32, Errno> Poll(std::vector<PollFD>& poll_fds, s32 timeout);