mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-19 03:50:59 +01:00
Merge pull request #12858 from liamwhite/non-blocking
internal_network: only poll for accept on blocking sockets
This commit is contained in:
commit
12e5293c73
2 changed files with 20 additions and 13 deletions
|
@ -693,6 +693,8 @@ std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
||||||
sockaddr_in addr;
|
sockaddr_in addr;
|
||||||
socklen_t addrlen = sizeof(addr);
|
socklen_t addrlen = sizeof(addr);
|
||||||
|
|
||||||
|
const bool wait_for_accept = !is_non_blocking;
|
||||||
|
if (wait_for_accept) {
|
||||||
std::vector<WSAPOLLFD> host_pollfds{
|
std::vector<WSAPOLLFD> host_pollfds{
|
||||||
WSAPOLLFD{fd, POLLIN, 0},
|
WSAPOLLFD{fd, POLLIN, 0},
|
||||||
WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
|
WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
|
||||||
|
@ -709,6 +711,7 @@ std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SOCKET new_socket = accept(fd, reinterpret_cast<sockaddr*>(&addr), &addrlen);
|
const SOCKET new_socket = accept(fd, reinterpret_cast<sockaddr*>(&addr), &addrlen);
|
||||||
|
|
||||||
|
@ -913,6 +916,7 @@ Errno Socket::SetRcvTimeo(u32 value) {
|
||||||
|
|
||||||
Errno Socket::SetNonBlock(bool enable) {
|
Errno Socket::SetNonBlock(bool enable) {
|
||||||
if (EnableNonBlock(fd, enable)) {
|
if (EnableNonBlock(fd, enable)) {
|
||||||
|
is_non_blocking = enable;
|
||||||
return Errno::SUCCESS;
|
return Errno::SUCCESS;
|
||||||
}
|
}
|
||||||
return GetAndLogLastError();
|
return GetAndLogLastError();
|
||||||
|
|
|
@ -166,6 +166,9 @@ public:
|
||||||
bool IsOpened() const override;
|
bool IsOpened() const override;
|
||||||
|
|
||||||
void HandleProxyPacket(const ProxyPacket& packet) 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);
|
std::pair<s32, Errno> Poll(std::vector<PollFD>& poll_fds, s32 timeout);
|
||||||
|
|
Loading…
Reference in a new issue