mirror of https://github.com/aria2/aria2
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.ccpull/1/head
parent
fabe7d98d4
commit
a53ee58746
|
@ -1,3 +1,12 @@
|
||||||
|
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
|
||||||
|
|
||||||
2010-04-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-04-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Updated doc for --event-poll option.
|
Updated doc for --event-poll option.
|
||||||
|
|
|
@ -224,6 +224,16 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#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()
|
void SelectEventPoll::updateFdSet()
|
||||||
{
|
{
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
@ -236,11 +246,24 @@ void SelectEventPoll::updateFdSet()
|
||||||
for(std::deque<SharedHandle<SocketEntry> >::const_iterator i =
|
for(std::deque<SharedHandle<SocketEntry> >::const_iterator i =
|
||||||
_socketEntries.begin(), eoi = _socketEntries.end(); i != eoi; ++i) {
|
_socketEntries.begin(), eoi = _socketEntries.end(); i != eoi; ++i) {
|
||||||
sock_t fd = (*i)->getSocket();
|
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();
|
int events = (*i)->getEvents();
|
||||||
if(events&EventPoll::EVENT_READ) {
|
if(events&EventPoll::EVENT_READ) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
checkFdCountMingw(_rfdset, _logger);
|
||||||
|
#endif // __MINGW32__
|
||||||
FD_SET(fd, &_rfdset);
|
FD_SET(fd, &_rfdset);
|
||||||
}
|
}
|
||||||
if(events&EventPoll::EVENT_WRITE) {
|
if(events&EventPoll::EVENT_WRITE) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
checkFdCountMingw(_wfdset, _logger);
|
||||||
|
#endif // __MINGW32__
|
||||||
FD_SET(fd, &_wfdset);
|
FD_SET(fd, &_wfdset);
|
||||||
}
|
}
|
||||||
if(_fdmax < fd) {
|
if(_fdmax < fd) {
|
||||||
|
|
|
@ -546,6 +546,14 @@ void SocketCore::closeConnection()
|
||||||
#endif // HAVE_LIBGNUTLS
|
#endif // HAVE_LIBGNUTLS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
# define CHECK_FD(fd) \
|
||||||
|
if(fd < 0 || FD_SETSIZE <= fd) { \
|
||||||
|
_logger->warn("Detected file descriptor >= FD_SETSIZE or < 0. " \
|
||||||
|
"Download may slow down or fail."); \
|
||||||
|
return false; \
|
||||||
|
}
|
||||||
|
#endif // !__MINGW32__
|
||||||
|
|
||||||
bool SocketCore::isWritable(time_t timeout)
|
bool SocketCore::isWritable(time_t timeout)
|
||||||
{
|
{
|
||||||
|
@ -564,6 +572,9 @@ bool SocketCore::isWritable(time_t timeout)
|
||||||
(StringFormat(EX_SOCKET_CHECK_WRITABLE, errorMsg()).str());
|
(StringFormat(EX_SOCKET_CHECK_WRITABLE, errorMsg()).str());
|
||||||
}
|
}
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
|
# ifndef __MINGW32__
|
||||||
|
CHECK_FD(sockfd);
|
||||||
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(sockfd, &fds);
|
FD_SET(sockfd, &fds);
|
||||||
|
@ -611,6 +622,9 @@ bool SocketCore::isReadable(time_t timeout)
|
||||||
(StringFormat(EX_SOCKET_CHECK_READABLE, errorMsg()).str());
|
(StringFormat(EX_SOCKET_CHECK_READABLE, errorMsg()).str());
|
||||||
}
|
}
|
||||||
#else // !HAVE_POLL
|
#else // !HAVE_POLL
|
||||||
|
# ifndef __MINGW32__
|
||||||
|
CHECK_FD(sockfd);
|
||||||
|
# endif // !__MINGW32__
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(sockfd, &fds);
|
FD_SET(sockfd, &fds);
|
||||||
|
|
Loading…
Reference in New Issue