summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-22 15:10:21 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-22 15:10:21 +0100
commit8eab4f83b9d184f608682639411c69acf21a958b (patch)
treec9d1139f4116b28062c4ddcb5e6dfb71827bd316 /source
parentAdded "primaryserverversion" to the "help" list. (diff)
downloadcuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar.gz
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar.bz2
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar.lz
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar.xz
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.tar.zst
cuberite-8eab4f83b9d184f608682639411c69acf21a958b.zip
Diffstat (limited to '')
-rw-r--r--source/OSSupport/Socket.cpp6
-rw-r--r--source/OSSupport/Socket.h14
-rw-r--r--source/OSSupport/SocketThreads.cpp6
3 files changed, 15 insertions, 11 deletions
diff --git a/source/OSSupport/Socket.cpp b/source/OSSupport/Socket.cpp
index d44a343e0..cad120fbe 100644
--- a/source/OSSupport/Socket.cpp
+++ b/source/OSSupport/Socket.cpp
@@ -51,12 +51,12 @@ cSocket::xSocket cSocket::GetSocket() const
-bool cSocket::IsValid(void) const
+bool cSocket::IsValidSocket(cSocket::xSocket a_Socket)
{
#ifdef _WIN32
- return (m_Socket != INVALID_SOCKET);
+ return (a_Socket != INVALID_SOCKET);
#else // _WIN32
- return (m_Socket >= 0);
+ return (a_Socket >= 0);
#endif // else _WIN32
}
diff --git a/source/OSSupport/Socket.h b/source/OSSupport/Socket.h
index f1c3f233c..43a80dca5 100644
--- a/source/OSSupport/Socket.h
+++ b/source/OSSupport/Socket.h
@@ -19,7 +19,7 @@ public:
cSocket(xSocket a_Socket);
~cSocket();
- bool IsValid(void) const;
+ bool IsValid(void) const { return IsValidSocket(m_Socket); }
void CloseSocket();
operator xSocket() const;
@@ -43,12 +43,14 @@ public:
inline static bool IsSocketError( int a_ReturnedValue )
{
-#ifdef _WIN32
- return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
-#else
- return (a_ReturnedValue <= 0);
-#endif
+ #ifdef _WIN32
+ return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
+ #else
+ return (a_ReturnedValue <= 0);
+ #endif
}
+
+ static bool IsValidSocket(xSocket a_Socket);
struct SockAddr_In
{
diff --git a/source/OSSupport/SocketThreads.cpp b/source/OSSupport/SocketThreads.cpp
index 13336a0c4..5058f3313 100644
--- a/source/OSSupport/SocketThreads.cpp
+++ b/source/OSSupport/SocketThreads.cpp
@@ -577,7 +577,8 @@ void cSocketThreads::cSocketThread::ReadFromSockets(fd_set * a_Read)
cCSLock Lock(m_Parent->m_CS);
for (int i = m_NumSlots - 1; i >= 0; --i)
{
- if (!FD_ISSET(m_Slots[i].m_Socket.GetSocket(), a_Read))
+ cSocket::xSocket Socket = m_Slots[i].m_Socket.GetSocket();
+ if (!cSocket::IsValidSocket(Socket) || !FD_ISSET(Socket, a_Read))
{
continue;
}
@@ -621,7 +622,8 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write)
cCSLock Lock(m_Parent->m_CS);
for (int i = m_NumSlots - 1; i >= 0; --i)
{
- if (!m_Slots[i].m_Socket.IsValid() || !FD_ISSET(m_Slots[i].m_Socket.GetSocket(), a_Write))
+ cSocket::xSocket Socket = m_Slots[i].m_Socket.GetSocket();
+ if (!cSocket::IsValidSocket(Socket) || !FD_ISSET(Socket, a_Write))
{
continue;
}