update
This commit is contained in:
parent
f1bf409981
commit
4630e0f642
13
das-dn/third_party/AdsLib/Sockets.cpp
vendored
13
das-dn/third_party/AdsLib/Sockets.cpp
vendored
@ -240,7 +240,10 @@ bool Socket::Select(timeval* timeout)
|
||||
{
|
||||
/* prepare socket set for select() */
|
||||
if (!IsValid()) {
|
||||
LOG_ERROR("Socket is invalid: " << std::dec << m_Socket);
|
||||
return false;
|
||||
}
|
||||
if (m_Socket < 0 || m_Socket >= FD_SETSIZE) {
|
||||
LOG_ERROR("received a non valid socket (" << m_Socket << "), unable to add to the set");
|
||||
return false;
|
||||
}
|
||||
fd_set readSockets;
|
||||
@ -251,6 +254,7 @@ bool Socket::Select(timeval* timeout)
|
||||
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
||||
if (0 == state) {
|
||||
LOG_ERROR("Socket select() timeout.");
|
||||
return false;
|
||||
//throw TimeoutEx("select() timeout");
|
||||
}
|
||||
|
||||
@ -258,6 +262,7 @@ bool Socket::Select(timeval* timeout)
|
||||
if (m_LastError == WSAENOTSOCK) {
|
||||
//throw std::runtime_error("connection closed");
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* and check if socket was correct */
|
||||
@ -266,7 +271,11 @@ bool Socket::Select(timeval* timeout)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!FD_ISSET(m_Socket, &readSockets))
|
||||
if (m_Socket < 0 || m_Socket >= FD_SETSIZE) {
|
||||
LOG_ERROR("received a non valid socket (" << m_Socket << "), unable to add to the set");
|
||||
return false;
|
||||
}
|
||||
if (!FD_ISSET(m_Socket, &readSockets))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user