Merge lp:~bhill/epics-base/pcas-deadlock-fix-3.14 into lp:~epics-core/epics-base/3.14

Proposed by Bruce Hill
Status: Merged
Approved by: Andrew Johnson
Approved revision: 12683
Merged at revision: 12686
Proposed branch: lp:~bhill/epics-base/pcas-deadlock-fix-3.14
Merge into: lp:~epics-core/epics-base/3.14
Diff against target: 83 lines (+12/-4)
3 files modified
src/cas/generic/casChannelI.cc (+1/-0)
src/cas/generic/casChannelI.h (+7/-0)
src/cas/generic/casStrmClient.cc (+4/-4)
To merge this branch: bzr merge lp:~bhill/epics-base/pcas-deadlock-fix-3.14
Reviewer Review Type Date Requested Status
Andrew Johnson Approve
Review via email: mp+312638@code.launchpad.net

Description of the change

Avoid deadlock when by moving call to casPVI::nativeCount()
out of the casEventSys processing to the casPVI constructor.
The nativeCount (max array size) doesn't change for a casPVI
instance so no need to lock the casPVI mutex each time we need
to test it's size.

To post a comment you must log in.
Revision history for this message
Andrew Johnson (anj) wrote :

Thanks Bruce, much appreciated!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/cas/generic/casChannelI.cc'
--- src/cas/generic/casChannelI.cc 2016-05-22 03:43:09 +0000
+++ src/cas/generic/casChannelI.cc 2016-12-07 09:42:35 +0000
@@ -21,6 +21,7 @@
21 casChannel & chanIn, casPVI & pvIn, ca_uint32_t cidIn ) :21 casChannel & chanIn, casPVI & pvIn, ca_uint32_t cidIn ) :
22 privateForPV ( clientIn, *this ),22 privateForPV ( clientIn, *this ),
23 pv ( pvIn ), 23 pv ( pvIn ),
24 maxElem( pvIn.nativeCount() ),
24 chan ( chanIn ), 25 chan ( chanIn ),
25 cid ( cidIn ), 26 cid ( cidIn ),
26 serverDeletePending ( false ), 27 serverDeletePending ( false ),
2728
=== modified file 'src/cas/generic/casChannelI.h'
--- src/cas/generic/casChannelI.h 2016-05-22 03:43:09 +0000
+++ src/cas/generic/casChannelI.h 2016-12-07 09:42:35 +0000
@@ -45,6 +45,7 @@
45 void clearOutstandingReads ();45 void clearOutstandingReads ();
46 void postAccessRightsEvent ();46 void postAccessRightsEvent ();
47 const gddEnumStringTable & enumStringTable () const;47 const gddEnumStringTable & enumStringTable () const;
48 ca_uint32_t getMaxElem () const;
48 void setOwner ( const char * const pUserName, 49 void setOwner ( const char * const pUserName,
49 const char * const pHostName );50 const char * const pHostName );
50 bool readAccess () const;51 bool readAccess () const;
@@ -58,6 +59,7 @@
58 chanIntfForPV privateForPV;59 chanIntfForPV privateForPV;
59 tsDLList < casAsyncIOI > ioList;60 tsDLList < casAsyncIOI > ioList;
60 casPVI & pv;61 casPVI & pv;
62 ca_uint32_t maxElem;
61 casChannel & chan;63 casChannel & chan;
62 caResId cid; // client id 64 caResId cid; // client id
63 bool serverDeletePending;65 bool serverDeletePending;
@@ -77,6 +79,11 @@
77 return this->pv;79 return this->pv;
78}80}
7981
82inline ca_uint32_t casChannelI::getMaxElem () const
83{
84 return this->maxElem;
85}
86
80inline const caResId casChannelI::getCID () 87inline const caResId casChannelI::getCID ()
81{88{
82 return this->cid;89 return this->cid;
8390
=== modified file 'src/cas/generic/casStrmClient.cc'
--- src/cas/generic/casStrmClient.cc 2016-11-30 17:58:24 +0000
+++ src/cas/generic/casStrmClient.cc 2016-12-07 09:42:35 +0000
@@ -409,7 +409,7 @@
409 //409 //
410 // element count out of range ?410 // element count out of range ?
411 //411 //
412 if ( ctx.msg.m_count > pChan->getPVI().nativeCount() ||412 if ( ctx.msg.m_count > pChan->getMaxElem() ||
413 ( !allowdyn && ctx.msg.m_count == 0u ) ) {413 ( !allowdyn && ctx.msg.m_count == 0u ) ) {
414 return ECA_BADCOUNT;414 return ECA_BADCOUNT;
415 }415 }
@@ -895,7 +895,7 @@
895 gdd * pDBRDD = 0;895 gdd * pDBRDD = 0;
896 if ( completionStatus == S_cas_success ) {896 if ( completionStatus == S_cas_success ) {
897 caStatus status = createDBRDD ( msg.m_dataType, count,897 caStatus status = createDBRDD ( msg.m_dataType, count,
898 chan.getPVI().nativeCount(), pDBRDD );898 chan.getMaxElem(), pDBRDD );
899 if ( status != S_cas_success ) {899 if ( status != S_cas_success ) {
900 caStatus ecaStatus;900 caStatus ecaStatus;
901 if ( status == S_cas_badType ) {901 if ( status == S_cas_badType ) {
@@ -1866,7 +1866,7 @@
1866 // the protocol buffer.1866 // the protocol buffer.
1867 //1867 //
1868 assert ( nativeTypeDBR <= 0xffff );1868 assert ( nativeTypeDBR <= 0xffff );
1869 aitIndex nativeCount = chan.getPVI().nativeCount();1869 aitIndex nativeCount = chan.getMaxElem();
1870 assert ( nativeCount <= 0xffffffff );1870 assert ( nativeCount <= 0xffffffff );
1871 assert ( hdr.m_cid == chan.getCID() );1871 assert ( hdr.m_cid == chan.getCID() );
1872 status = this->out.copyInHeader ( CA_PROTO_CREATE_CHAN, 0,1872 status = this->out.copyInHeader ( CA_PROTO_CREATE_CHAN, 0,
@@ -2626,7 +2626,7 @@
2626 {2626 {
2627 gdd * pDD = 0;2627 gdd * pDD = 0;
2628 caStatus status = createDBRDD ( pHdr->m_dataType, pHdr->m_count,2628 caStatus status = createDBRDD ( pHdr->m_dataType, pHdr->m_count,
2629 this->ctx.getChannel()->getPVI().nativeCount(), pDD );2629 this->ctx.getChannel()->getMaxElem(), pDD );
2630 if ( status != S_cas_success ) {2630 if ( status != S_cas_success ) {
2631 return status;2631 return status;
2632 }2632 }

Subscribers

People subscribed via source and target branches