execute shutdown locgic with lock applied

This commit is contained in:
Jeff Hill
2000-08-30 17:07:28 +00:00
parent e066e5c22a
commit 67bbc1aef2
2 changed files with 10 additions and 28 deletions

View File

@@ -512,19 +512,9 @@ tcpiiu::tcpiiu ( cac &cac, const osiSockAddr &addrIn,
*/
void tcpiiu::shutdown ()
{
bool laborNeeded;
this->lock ();
if ( this->state != iiu_disconnected ) {
this->state = iiu_disconnected;
laborNeeded = true;
}
else {
laborNeeded = false;
}
this->unlock ();
if ( laborNeeded ) {
//
// using shutdown () here initiates a graceful socket
// shutdown sequence which will linger on the CA echo
@@ -542,6 +532,7 @@ void tcpiiu::shutdown ()
this->recvPending = true;
this->clientCtx ().signalRecvActivity ();
}
this->unlock ();
}
//
@@ -558,9 +549,9 @@ tcpiiu::~tcpiiu ()
this->shutdown ();
if ( this->channelCount () ) {
char hostName[64];
this->ipToA.hostName ( hostName, sizeof ( hostName ) );
genLocalExcep ( this->clientCtx (), ECA_DISCONN, hostName );
char hostNameTmp[64];
this->ipToA.hostName ( hostNameTmp, sizeof ( hostNameTmp ) );
genLocalExcep ( this->clientCtx (), ECA_DISCONN, hostNameTmp );
}
this->disconnectAllChan ();
@@ -986,7 +977,7 @@ void tcpiiu::postMsg ()
*/
pProtoStubTCP pStub;
if ( this->curMsg.m_cmmd >= NELEMENTS ( tcpJumpTableCAC ) ) {
pStub = badTCPRespAction;
pStub = &tcpiiu::badTCPRespAction;
}
else {
pStub = tcpJumpTableCAC [this->curMsg.m_cmmd];

View File

@@ -444,23 +444,13 @@ udpiiu::~udpiiu ()
*/
void udpiiu::shutdown ()
{
bool laborRequired;
this->lock ();
if ( ! this->shutdownCmd ) {
this->shutdownCmd = true;
laborRequired = true;
}
else {
laborRequired = false;
}
this->unlock ();
if ( laborRequired ) {
int status;
osiSockAddr addr;
osiSocklen_t size = sizeof ( addr.sa );
this->shutdownCmd = true;
status = getsockname ( this->sock, &addr.sa, &size );
if ( status < 0 ) {
// this knocks the UDP input thread out of recv ()
@@ -480,8 +470,8 @@ void udpiiu::shutdown ()
addr.ia.sin_addr.s_addr = htonl ( INADDR_LOOPBACK );
// send a wakeup msg so the UDP recv thread will exit
status = sendto ( this->sock, reinterpret_cast < const char * > ( &msg ), sizeof (msg), 0,
&addr.sa, sizeof ( addr.sa ) );
status = sendto ( this->sock, reinterpret_cast < const char * > ( &msg ),
sizeof (msg), 0, &addr.sa, sizeof ( addr.sa ) );
if ( status < 0 ) {
// this knocks the UDP input thread out of recv ()
// on all os except linux
@@ -490,6 +480,7 @@ void udpiiu::shutdown ()
}
}
}
this->unlock ();
}
void udpiiu::badUDPRespAction ( const caHdr &msg, const osiSockAddr &netAddr )
@@ -693,7 +684,7 @@ int udpiiu::postMsg ( const osiSockAddr &net_addr,
*/
pProtoStubUDP pStub;
if ( pCurMsg->m_cmmd >= NELEMENTS ( udpJumpTableCAC ) ) {
pStub = badUDPRespAction;
pStub = &udpiiu::badUDPRespAction;
}
else {
pStub = udpJumpTableCAC [pCurMsg->m_cmmd];