mirror of https://github.com/aria2/aria2
Merge pull request #1061 from aria2/fix-win-select
mingw: Fix high CPU usage in BitTorrent downloadspull/1064/head
commit
3c6a70c566
|
@ -174,6 +174,12 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
|
|
||||||
memcpy(&rfds, &rfdset_, sizeof(fd_set));
|
memcpy(&rfds, &rfdset_, sizeof(fd_set));
|
||||||
memcpy(&wfds, &wfdset_, sizeof(fd_set));
|
memcpy(&wfds, &wfdset_, sizeof(fd_set));
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
fd_set efds;
|
||||||
|
memcpy(&efds, &wfdset_, sizeof(fd_set));
|
||||||
|
#endif // __MINGW32__
|
||||||
|
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
for (auto& i : nameResolverEntries_) {
|
for (auto& i : nameResolverEntries_) {
|
||||||
|
@ -190,11 +196,9 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
do {
|
do {
|
||||||
struct timeval ttv = tv;
|
struct timeval ttv = tv;
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
// winsock will report non-blocking connect() errors in exceptfds, unlike
|
// winsock will report non-blocking connect() errors in efds,
|
||||||
// posix, which will mark such sockets as writable.
|
// unlike posix, which will mark such sockets as writable.
|
||||||
// So just pass in our write socket set to exceptfds, too, to get connect()
|
retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv);
|
||||||
// error notifications on Windows.
|
|
||||||
retval = select(fdmax_ + 1, &rfds, &wfds, &wfds, &ttv);
|
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
retval = select(fdmax_ + 1, &rfds, &wfds, nullptr, &ttv);
|
retval = select(fdmax_ + 1, &rfds, &wfds, nullptr, &ttv);
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
|
@ -209,6 +213,11 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
if (FD_ISSET(e.getSocket(), &wfds)) {
|
if (FD_ISSET(e.getSocket(), &wfds)) {
|
||||||
events |= EventPoll::EVENT_WRITE;
|
events |= EventPoll::EVENT_WRITE;
|
||||||
}
|
}
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (FD_ISSET(e.getSocket(), &efds)) {
|
||||||
|
events |= EventPoll::EVENT_ERROR;
|
||||||
|
}
|
||||||
|
#endif // __MINGW32__
|
||||||
e.processEvents(events);
|
e.processEvents(events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue