summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bus/Ivy/ThreadedSocket.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/Bus/Ivy/ThreadedSocket.cxx b/Bus/Ivy/ThreadedSocket.cxx
index 2f32a26..3934095 100644
--- a/Bus/Ivy/ThreadedSocket.cxx
+++ b/Bus/Ivy/ThreadedSocket.cxx
@@ -128,8 +128,11 @@ void CThreadedSocket::Close()
if (m_hSocket != INVALID_SOCKET)
{
//ASSERT(SOCKET_ERROR != closesocket(m_hSocket));
- closesocket(m_hSocket); // close silently
+ SOCKET temp = m_hSocket; // Thread ACK
m_hSocket = INVALID_SOCKET;
+ TRACE( "CThreadedSocket::Close (reader=0x%0x) (writer=0x%0x)%\n", reader_id, writer_id );
+ closesocket(temp); // close silently
+
//if ( thread ) // On fait de l'auto delete mais dans le cas de terminaison anormale l'object reste ????!!!
// delete thread;
// TRACE("CThreadedSocket waiting for thread end ...\n");
@@ -417,9 +420,9 @@ UINT CThreadedSocket::SocketReader( )
break;
case SOCKET_ERROR:
- TRACE( "CThreadedSocket::SocketReader( select error thread_id =( %d) )\n",reader_id);
-
- Close();
+ TRACE( "CThreadedSocket::SocketReader( select error thread_id =( 0x%x) )\n",reader_id);
+ if ( (sock_err != WSAENOTSOCK ) && ( m_hSocket != INVALID_SOCKET )) // could be Invalid if close when in select
+ Close();
h_reader = NULL;
return sock_err;
break;
@@ -512,7 +515,8 @@ UINT CThreadedSocket::SocketWriter( )
break;
case SOCKET_ERROR:
TRACE( "CThreadedSocketException( select )\n");
- if (m_hSocket != INVALID_SOCKET) Close();
+ if ( (sock_err != WSAENOTSOCK ) && ( m_hSocket != INVALID_SOCKET )) // could be Invalid if close when in select
+ Close();
h_reader = NULL;
return sock_err;
break;