From 9a885db4d193dcdea69ac1464b1c9ea11d567cfa Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 15 Jun 2000 20:46:29 +0000 Subject: [PATCH] fixed recv thread shutdown bug --- src/ca/tcpiiu.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/ca/tcpiiu.cpp b/src/ca/tcpiiu.cpp index d549a84bb..c380aa1a8 100644 --- a/src/ca/tcpiiu.cpp +++ b/src/ca/tcpiiu.cpp @@ -179,11 +179,11 @@ extern "C" void cacSendThreadTCP (void *pParam) pOutBuf = static_cast ( cacRingBufferReadReserveNoBlock (&piiu->send, &sendCnt) ); while ( ! pOutBuf ) { piiu->cancelSendWatchdog (); - pOutBuf = (char *) cacRingBufferReadReserve (&piiu->send, &sendCnt); if ( piiu->state != iiu_connected ) { semBinaryGive ( piiu->sendThreadExitSignal ); return; } + pOutBuf = (char *) cacRingBufferReadReserve (&piiu->send, &sendCnt); } assert ( sendCnt <= INT_MAX ); @@ -248,14 +248,17 @@ void tcpiiu::recvMsg () return; } - pProto = (char *) cacRingBufferWriteReserve (&this->recv, &writeSpace); - + pProto = (char *) cacRingBufferWriteReserve ( &this->recv, &writeSpace ); + if ( ! pProto ) { + return; + } + assert ( writeSpace <= INT_MAX ); status = ::recv ( this->sock, pProto, (int) writeSpace, 0); if ( status <= 0 ) { int localErrno = SOCKERRNO; - cacRingBufferWriteCommit (&this->recv, 0); + cacRingBufferWriteCommit ( &this->recv, 0 ); if ( status == 0 ) { this->shutdown (); @@ -270,8 +273,19 @@ void tcpiiu::recvMsg () return; } - ca_printf ( "Disconnecting from CA server because: %s\n", SOCKERRSTR (localErrno) ); + if ( localErrno == SOCK_ECONNABORTED ) { + return; + } + + { + char name[64]; + this->hostName ( name, sizeof (name) ); + ca_printf ( "Disconnecting from CA server %s because: %s\n", + name, SOCKERRSTR (localErrno) ); + } + this->shutdown (); + return; }