From f7bfbf73f8c386341c7992fd8fb4545d5579077f Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 7 Jul 2009 23:09:21 +0000 Subject: [PATCH] additional patches for memory leaks (see mantis 340) --- src/cas/generic/casStrmClient.cc | 32 +++++++++++++------------------- src/cas/generic/casStrmClient.h | 2 +- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/cas/generic/casStrmClient.cc b/src/cas/generic/casStrmClient.cc index 1d4ce9252..8dc98024e 100644 --- a/src/cas/generic/casStrmClient.cc +++ b/src/cas/generic/casStrmClient.cc @@ -426,7 +426,6 @@ caStatus casStrmClient::readAction ( epicsGuard < casClientMutex > & guard ) const caHdrLargeArray * mp = this->ctx.getMsg(); caStatus status; casChannelI * pChan; - const gdd * pDesc; status = this->verifyRequest ( pChan ); if ( status != ECA_NORMAL ) { @@ -458,9 +457,11 @@ caStatus casStrmClient::readAction ( epicsGuard < casClientMutex > & guard ) status, "read access denied" ); } + const gdd * pDesc = 0; status = this->read ( pDesc ); if ( status == S_casApp_success ) { status = this->readResponse ( guard, pChan, *mp, *pDesc, S_cas_success ); + pDesc->unreference (); } else if ( status == S_casApp_asyncCompletion ) { status = S_cas_success; @@ -473,10 +474,6 @@ caStatus casStrmClient::readAction ( epicsGuard < casClientMutex > & guard ) pChan->getCID(), status, ECA_GETFAIL ); } - if ( pDesc ) { - pDesc->unreference (); - } - return status; } @@ -544,7 +541,6 @@ caStatus casStrmClient::readNotifyAction ( epicsGuard < casClientMutex > & guard { const caHdrLargeArray * mp = this->ctx.getMsg(); casChannelI * pChan; - const gdd * pDesc; int status; status = this->verifyRequest ( pChan ); @@ -561,9 +557,11 @@ caStatus casStrmClient::readNotifyAction ( epicsGuard < casClientMutex > & guard return this->readNotifyFailureResponse ( guard, *mp, ECA_NORDACCESS ); } + const gdd * pDesc = 0; status = this->read ( pDesc ); if ( status == S_casApp_success ) { status = this->readNotifyResponse ( guard, pChan, *mp, *pDesc, status ); + pDesc->unreference (); } else if ( status == S_casApp_asyncCompletion ) { status = S_cas_success; @@ -572,13 +570,9 @@ caStatus casStrmClient::readNotifyAction ( epicsGuard < casClientMutex > & guard pChan->getPVI().addItemToIOBLockedList ( *this ); } else { - status = this->readNotifyResponse ( guard, pChan, *mp, *pDesc, status ); + status = this->readNotifyFailureResponse ( guard, *mp, ECA_GETFAIL ); } - if ( pDesc ) { - pDesc->unreference (); - } - return status; } @@ -1634,12 +1628,17 @@ caStatus casStrmClient::eventAddAction ( // to postpone asynchronous IO we can safely restart this // request later. // - const gdd * pDD; + const gdd * pDD = 0; status = this->read ( pDD ); // // always send immediate monitor response at event add // - if ( status == S_casApp_asyncCompletion ) { + if ( status == S_cas_success ) { + status = this->monitorResponse ( guard, *pciu, + *mp, *pDD, status ); + pDD->unreference (); + } + else if ( status == S_casApp_asyncCompletion ) { status = S_cas_success; } else if ( status == S_casApp_postponeAsyncIO ) { @@ -1649,8 +1648,7 @@ caStatus casStrmClient::eventAddAction ( pciu->getPVI().addItemToIOBLockedList ( *this ); } else { - status = this->monitorResponse ( guard, *pciu, - *mp, *pDD, status ); + status = this->monitorFailureResponse ( guard, *mp, ECA_GETFAIL ); } if ( status == S_cas_success ) { @@ -1660,10 +1658,6 @@ caStatus casStrmClient::eventAddAction ( pciu->installMonitor ( mon ); } - if ( pDD ) { - pDD->unreference (); - } - return status; } diff --git a/src/cas/generic/casStrmClient.h b/src/cas/generic/casStrmClient.h index 49a8abfa2..c2523c5a5 100644 --- a/src/cas/generic/casStrmClient.h +++ b/src/cas/generic/casStrmClient.h @@ -123,7 +123,7 @@ private: const caHdrLargeArray &, const caStatus status ); caStatus monitorResponse ( epicsGuard < casClientMutex > &, casChannelI & chan, const caHdrLargeArray & msg, - const gdd & desc, const caStatus status ); + const gdd &, const caStatus status ); caStatus enumPostponedCreateChanResponse ( epicsGuard < casClientMutex > &, casChannelI & chan, const caHdrLargeArray & hdr ); caStatus privateCreateChanResponse ( epicsGuard < casClientMutex > &,