diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-04-25 13:49:31 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-04-25 13:49:31 +0000 |
| commit | a53ee58746ea6247169fbf86e7b8e3ed81c1eb40 (patch) | |
| tree | 1a517d06e6ed52eab0579ba7f8787e71aeb2503d /src/SelectEventPoll.cc | |
| parent | fabe7d98d4db8dc42b3aaa877397d501dd89fb13 (diff) | |
2010-04-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Print warning when trying to add file descriptor >= FD_SET or < 0
to fd_set for other than MinGW32 build. For MinGW32 build, print
warning when trying to add file descriptor to fd_set when it
already contains FD_SET file descriptors.
* src/SelectEventPoll.cc
* src/SocketCore.cc
Diffstat (limited to 'src/SelectEventPoll.cc')
| -rw-r--r-- | src/SelectEventPoll.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index e95c0ab5..9a61df5c 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -224,6 +224,16 @@ void SelectEventPoll::poll(const struct timeval& tv) #endif // ENABLE_ASYNC_DNS } +#ifdef __MINGW32__ +static void checkFdCountMingw(const fd_set& fdset, Logger* logger) +{ + if(fdset.fd_count >= FD_SETSIZE) { + logger->warn("The number of file descriptor exceeded FD_SETSIZE. " + "Download may slow down or fail."); + } +} +#endif // __MINGW32__ + void SelectEventPoll::updateFdSet() { #ifdef __MINGW32__ @@ -236,11 +246,24 @@ void SelectEventPoll::updateFdSet() for(std::deque<SharedHandle<SocketEntry> >::const_iterator i = _socketEntries.begin(), eoi = _socketEntries.end(); i != eoi; ++i) { sock_t fd = (*i)->getSocket(); +#ifndef __MINGW32__ + if(fd < 0 || FD_SETSIZE <= fd) { + _logger->warn("Detected file descriptor >= FD_SETSIZE or < 0. " + "Download may slow down or fail."); + continue; + } +#endif // !__MINGW32__ int events = (*i)->getEvents(); if(events&EventPoll::EVENT_READ) { +#ifdef __MINGW32__ + checkFdCountMingw(_rfdset, _logger); +#endif // __MINGW32__ FD_SET(fd, &_rfdset); } if(events&EventPoll::EVENT_WRITE) { +#ifdef __MINGW32__ + checkFdCountMingw(_wfdset, _logger); +#endif // __MINGW32__ FD_SET(fd, &_wfdset); } if(_fdmax < fd) { |
