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() */
|
/* prepare socket set for select() */
|
||||||
if (!IsValid()) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
fd_set readSockets;
|
fd_set readSockets;
|
||||||
@ -251,6 +254,7 @@ bool Socket::Select(timeval* timeout)
|
|||||||
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
||||||
if (0 == state) {
|
if (0 == state) {
|
||||||
LOG_ERROR("Socket select() timeout.");
|
LOG_ERROR("Socket select() timeout.");
|
||||||
|
return false;
|
||||||
//throw TimeoutEx("select() timeout");
|
//throw TimeoutEx("select() timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +262,7 @@ bool Socket::Select(timeval* timeout)
|
|||||||
if (m_LastError == WSAENOTSOCK) {
|
if (m_LastError == WSAENOTSOCK) {
|
||||||
//throw std::runtime_error("connection closed");
|
//throw std::runtime_error("connection closed");
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and check if socket was correct */
|
/* and check if socket was correct */
|
||||||
@ -266,7 +271,11 @@ bool Socket::Select(timeval* timeout)
|
|||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user