From d3568605ce7bbd5d063a77f2f2a29f83a23cee3c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 6 Dec 2016 13:43:59 -0800 Subject: [PATCH] Fetch nativeCount() in casChannelI constructor to avoid deadlock if we fetch it from eventSysProcess() --- src/cas/generic/casChannelI.cc | 1 + src/cas/generic/casChannelI.h | 7 +++++++ src/cas/generic/casStrmClient.cc | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cas/generic/casChannelI.cc b/src/cas/generic/casChannelI.cc index 588f67d78..c575ea483 100644 --- a/src/cas/generic/casChannelI.cc +++ b/src/cas/generic/casChannelI.cc @@ -21,6 +21,7 @@ casChannelI::casChannelI ( casCoreClient & clientIn, casChannel & chanIn, casPVI & pvIn, ca_uint32_t cidIn ) : privateForPV ( clientIn, *this ), pv ( pvIn ), + maxElem( pvIn.nativeCount() ), chan ( chanIn ), cid ( cidIn ), serverDeletePending ( false ), diff --git a/src/cas/generic/casChannelI.h b/src/cas/generic/casChannelI.h index 2c72e88e4..228fe6ab3 100644 --- a/src/cas/generic/casChannelI.h +++ b/src/cas/generic/casChannelI.h @@ -45,6 +45,7 @@ public: void clearOutstandingReads (); void postAccessRightsEvent (); const gddEnumStringTable & enumStringTable () const; + ca_uint32_t getMaxElem () const; void setOwner ( const char * const pUserName, const char * const pHostName ); bool readAccess () const; @@ -58,6 +59,7 @@ private: chanIntfForPV privateForPV; tsDLList < casAsyncIOI > ioList; casPVI & pv; + ca_uint32_t maxElem; casChannel & chan; caResId cid; // client id bool serverDeletePending; @@ -77,6 +79,11 @@ inline casPVI & casChannelI::getPVI () const return this->pv; } +inline ca_uint32_t casChannelI::getMaxElem () const +{ + return this->maxElem; +} + inline const caResId casChannelI::getCID () { return this->cid; diff --git a/src/cas/generic/casStrmClient.cc b/src/cas/generic/casStrmClient.cc index e23a2b8df..60903787c 100644 --- a/src/cas/generic/casStrmClient.cc +++ b/src/cas/generic/casStrmClient.cc @@ -409,7 +409,7 @@ caStatus casStrmClient::verifyRequest (casChannelI * & pChan , bool allowdyn) // // element count out of range ? // - if ( ctx.msg.m_count > pChan->getPVI().nativeCount() || + if ( ctx.msg.m_count > pChan->getMaxElem() || ( !allowdyn && ctx.msg.m_count == 0u ) ) { return ECA_BADCOUNT; } @@ -895,7 +895,7 @@ caStatus casStrmClient::monitorResponse ( gdd * pDBRDD = 0; if ( completionStatus == S_cas_success ) { caStatus status = createDBRDD ( msg.m_dataType, count, - chan.getPVI().nativeCount(), pDBRDD ); + chan.getMaxElem(), pDBRDD ); if ( status != S_cas_success ) { caStatus ecaStatus; if ( status == S_cas_badType ) { @@ -1866,7 +1866,7 @@ caStatus casStrmClient::privateCreateChanResponse ( // the protocol buffer. // assert ( nativeTypeDBR <= 0xffff ); - aitIndex nativeCount = chan.getPVI().nativeCount(); + aitIndex nativeCount = chan.getMaxElem(); assert ( nativeCount <= 0xffffffff ); assert ( hdr.m_cid == chan.getCID() ); status = this->out.copyInHeader ( CA_PROTO_CREATE_CHAN, 0, @@ -2626,7 +2626,7 @@ caStatus casStrmClient::read () { gdd * pDD = 0; caStatus status = createDBRDD ( pHdr->m_dataType, pHdr->m_count, - this->ctx.getChannel()->getPVI().nativeCount(), pDD ); + this->ctx.getChannel()->getMaxElem(), pDD ); if ( status != S_cas_success ) { return status; }