From d57666d6180fe49053496afaa199a808cfe6c06b Mon Sep 17 00:00:00 2001 From: kwkam Date: Sun, 5 Nov 2017 01:13:38 +0800 Subject: [PATCH] SelectEventPoll: temporary restore to select efds after 1fe6cc7 cpu usage was drastically increased --- src/SelectEventPoll.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index 824c5088..8c3e6317 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -174,6 +174,18 @@ void SelectEventPoll::poll(const struct timeval& tv) memcpy(&rfds, &rfdset_, sizeof(fd_set)); memcpy(&wfds, &wfdset_, sizeof(fd_set)); +#ifdef __MINGW32__ + fd_set efds; + FD_ZERO(&efds); + FD_SET(dummySocket_, &efds); + + if (rfds.fd_count <= 0) { + FD_SET(dummySocket_, &rfds); + } + if (wfds.fd_count <= 0) { + FD_SET(dummySocket_, &wfds); + } +#endif // __MINGW32__ #ifdef ENABLE_ASYNC_DNS for (auto& i : nameResolverEntries_) { @@ -190,11 +202,10 @@ void SelectEventPoll::poll(const struct timeval& tv) do { struct timeval ttv = tv; #ifdef __MINGW32__ + // TODO // winsock will report non-blocking connect() errors in exceptfds, unlike // posix, which will mark such sockets as writable. - // So just pass in our write socket set to exceptfds, too, to get connect() - // error notifications on Windows. - retval = select(fdmax_ + 1, &rfds, &wfds, &wfds, &ttv); + retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv); #else // !__MINGW32__ retval = select(fdmax_ + 1, &rfds, &wfds, nullptr, &ttv); #endif // !__MINGW32__ @@ -243,8 +254,6 @@ void SelectEventPoll::updateFdSet() FD_ZERO(&rfdset_); FD_ZERO(&wfdset_); #ifdef __MINGW32__ - FD_SET(dummySocket_, &rfdset_); - FD_SET(dummySocket_, &wfdset_); fdmax_ = dummySocket_; #else // !__MINGW32__ fdmax_ = 0;