fixed recv thread shutdown bug

This commit is contained in:
Jeff Hill
2000-06-15 20:46:29 +00:00
parent 0185bd2fba
commit 9a885db4d1
+19 -5
View File
@@ -179,11 +179,11 @@ extern "C" void cacSendThreadTCP (void *pParam)
pOutBuf = static_cast <char *> ( 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;
}