|
|
@ -693,20 +693,23 @@ std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
|
|
|
sockaddr_in addr;
|
|
|
|
sockaddr_in addr;
|
|
|
|
socklen_t addrlen = sizeof(addr);
|
|
|
|
socklen_t addrlen = sizeof(addr);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<WSAPOLLFD> host_pollfds{
|
|
|
|
const bool wait_for_accept = !is_non_blocking;
|
|
|
|
WSAPOLLFD{fd, POLLIN, 0},
|
|
|
|
if (wait_for_accept) {
|
|
|
|
WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
|
|
|
|
std::vector<WSAPOLLFD> host_pollfds{
|
|
|
|
};
|
|
|
|
WSAPOLLFD{fd, POLLIN, 0},
|
|
|
|
|
|
|
|
WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
const int pollres =
|
|
|
|
const int pollres =
|
|
|
|
WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), -1);
|
|
|
|
WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), -1);
|
|
|
|
if (host_pollfds[1].revents != 0) {
|
|
|
|
if (host_pollfds[1].revents != 0) {
|
|
|
|
// Interrupt signaled before a client could be accepted, break
|
|
|
|
// Interrupt signaled before a client could be accepted, break
|
|
|
|
return {AcceptResult{}, Errno::AGAIN};
|
|
|
|
return {AcceptResult{}, Errno::AGAIN};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pollres > 0) {
|
|
|
|
if (pollres > 0) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -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();
|
|
|
|