diff options
author | fcolin | 2007-02-01 13:05:36 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:05:36 +0000 |
commit | 00d85a7fcb3d1709dc555174f0eddbb6d1e5add4 (patch) | |
tree | 9f99b831f1b986c73da0c087f251d63ea11c62ad /Bus | |
parent | 0937d158e7b20899e3adcdde078f9bb9a0951ce3 (diff) | |
download | ivy-cplusplus-00d85a7fcb3d1709dc555174f0eddbb6d1e5add4.zip ivy-cplusplus-00d85a7fcb3d1709dc555174f0eddbb6d1e5add4.tar.gz ivy-cplusplus-00d85a7fcb3d1709dc555174f0eddbb6d1e5add4.tar.bz2 ivy-cplusplus-00d85a7fcb3d1709dc555174f0eddbb6d1e5add4.tar.xz |
Utilisateur : Fcolin Date : 18/11/05 Heure : 11:46 Archivé dans $/Bus/Ivy Commentaire: repassage a la STL et correction bug multithread (vss 25)
Diffstat (limited to 'Bus')
-rw-r--r-- | Bus/Ivy/ThreadedSocket.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Bus/Ivy/ThreadedSocket.cxx b/Bus/Ivy/ThreadedSocket.cxx index 610f9b7..ee1e03b 100644 --- a/Bus/Ivy/ThreadedSocket.cxx +++ b/Bus/Ivy/ThreadedSocket.cxx @@ -16,9 +16,11 @@ CThreadedSocket::CThreadedSocket()
{
- m_hSocket = INVALID_SOCKET;
+ m_hSocket = INVALID_SOCKET;
h_reader = NULL;
h_writer = NULL;
+ reader_id = 0;
+ writer_id = 0;
listen_mode = false;
connect_pending = true;
send_pending = false;
@@ -125,8 +127,13 @@ void CThreadedSocket::Close() {
long PreviousCount = 0;
int err;
+ DWORD currentThreadId;
+
+
if (m_hSocket != INVALID_SOCKET)
{
+ currentThreadId = GetCurrentThreadId();
+
//ASSERT(SOCKET_ERROR != closesocket(m_hSocket));
SOCKET temp = m_hSocket; // Thread ACK
m_hSocket = INVALID_SOCKET;
@@ -136,9 +143,10 @@ void CThreadedSocket::Close() //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");
- if ( h_reader ) WaitForSingleObject( h_reader, 5000 );
+ if ( h_reader && currentThreadId != reader_id )
+ WaitForSingleObject( h_reader, 5000 );
// wake up writer
- if ( h_writer )
+ if ( h_writer && currentThreadId != writer_id )
{
err = ReleaseSemaphore(send_count, 1, &PreviousCount);
WaitForSingleObject( h_writer, 5000 );
@@ -533,7 +541,7 @@ UINT CThreadedSocket::SocketWriter( ) }
Close();
h_writer = NULL;
-// TRACE( "CThreadedSocket::SocketWriter( END thread_id =( 0x%x) )\n",writer_id);
+ TRACE( "CThreadedSocket::SocketWriter( END thread_id =( 0x%x) )\n",writer_id);
return 0;
}
|