summaryrefslogtreecommitdiff
path: root/src/SocketCore.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-04-25 13:49:31 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-04-25 13:49:31 +0000
commita53ee58746ea6247169fbf86e7b8e3ed81c1eb40 (patch)
tree1a517d06e6ed52eab0579ba7f8787e71aeb2503d /src/SocketCore.cc
parentfabe7d98d4db8dc42b3aaa877397d501dd89fb13 (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/SocketCore.cc')
-rw-r--r--src/SocketCore.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc
index c35b6f13..3cc7374a 100644
--- a/src/SocketCore.cc
+++ b/src/SocketCore.cc
@@ -546,6 +546,14 @@ void SocketCore::closeConnection()
#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)
{
@@ -564,6 +572,9 @@ bool SocketCore::isWritable(time_t timeout)
(StringFormat(EX_SOCKET_CHECK_WRITABLE, errorMsg()).str());
}
#else // !HAVE_POLL
+# ifndef __MINGW32__
+ CHECK_FD(sockfd);
+# endif // !__MINGW32__
fd_set fds;
FD_ZERO(&fds);
FD_SET(sockfd, &fds);
@@ -611,6 +622,9 @@ bool SocketCore::isReadable(time_t timeout)
(StringFormat(EX_SOCKET_CHECK_READABLE, errorMsg()).str());
}
#else // !HAVE_POLL
+# ifndef __MINGW32__
+ CHECK_FD(sockfd);
+# endif // !__MINGW32__
fd_set fds;
FD_ZERO(&fds);
FD_SET(sockfd, &fds);