made lib more robust if server sends duplicate connect channel response

This commit is contained in:
Jeff Hill
2009-07-14 22:39:41 +00:00
parent 7d2be4f947
commit d7ae0fbce6
3 changed files with 16 additions and 5 deletions

View File

@@ -1046,9 +1046,16 @@ bool cac::createChannelRespAction (
else {
sidTmp = pChan->getSID (guard);
}
iiu.connectNotify ( guard, *pChan );
pChan->connect ( hdr.m_dataType, hdr.m_count, sidTmp,
mgr.cbGuard, guard );
bool wasExpected = iiu.connectNotify ( guard, *pChan );
if ( wasExpected ) {
pChan->connect ( hdr.m_dataType, hdr.m_count, sidTmp,
mgr.cbGuard, guard );
}
else {
errlogPrintf (
"CA Client Library: Ignored duplicate create channel "
"response from CA server?\n" );
}
}
else if ( iiu.ca_v44_ok ( guard ) ) {
// this indicates a claim response for a resource that does

View File

@@ -1916,24 +1916,28 @@ void tcpiiu::nameResolutionMsgEndNotify ()
}
}
void tcpiiu::connectNotify (
bool tcpiiu :: connectNotify (
epicsGuard < epicsMutex > & guard, nciu & chan )
{
guard.assertIdenticalMutex ( this->mutex );
bool wasExpected = false;
// this improves robustness in the face of a server sending
// protocol that does not match its declared protocol revision
if ( chan.channelNode::listMember == channelNode::cs_createRespPend ) {
this->createRespPend.remove ( chan );
this->subscripReqPend.add ( chan );
chan.channelNode::listMember = channelNode::cs_subscripReqPend;
wasExpected = true;
}
else if ( chan.channelNode::listMember == channelNode::cs_v42ConnCallbackPend ) {
this->v42ConnCallbackPend.remove ( chan );
this->subscripReqPend.add ( chan );
chan.channelNode::listMember = channelNode::cs_subscripReqPend;
wasExpected = true;
}
// the TCP send thread is awakened by its receive thread whenever the receive thread
// is about to block if this->subscripReqPend has items in it
return wasExpected;
}
void tcpiiu::uninstallChan (

View File

@@ -173,7 +173,7 @@ public:
unsigned sidIn, ca_uint16_t typeIn, arrayElementCount countIn );
void uninstallChan (
epicsGuard < epicsMutex > & guard, nciu & chan );
void connectNotify (
bool connectNotify (
epicsGuard < epicsMutex > &, nciu & chan );
void nameResolutionMsgEndNotify ();