summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
authorfcolin2007-02-01 13:05:36 +0000
committerfcolin2007-02-01 13:05:36 +0000
commit79e97e573fc073eb9554ca0b89e2d0580e89a286 (patch)
treed73367934d7b34f7c51576ac745c24c272af96f0 /Ivy
parentbc919bfe58f3dd881182082570f1c2424612734d (diff)
downloadivy-cplusplus-79e97e573fc073eb9554ca0b89e2d0580e89a286.zip
ivy-cplusplus-79e97e573fc073eb9554ca0b89e2d0580e89a286.tar.gz
ivy-cplusplus-79e97e573fc073eb9554ca0b89e2d0580e89a286.tar.bz2
ivy-cplusplus-79e97e573fc073eb9554ca0b89e2d0580e89a286.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 'Ivy')
-rw-r--r--Ivy/ThreadedSocket.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/Ivy/ThreadedSocket.cxx b/Ivy/ThreadedSocket.cxx
index 610f9b7..ee1e03b 100644
--- a/Ivy/ThreadedSocket.cxx
+++ b/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;
}