From c06e33e19770b64953ba07b557e36ce21de0bb12 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Mon, 9 Jun 2014 07:55:08 -0400 Subject: [PATCH] better implementation of ChannelArray::getLength --- src/pvAccess/channelLocal.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/pvAccess/channelLocal.cpp b/src/pvAccess/channelLocal.cpp index f7f8255..fa0404d 100644 --- a/src/pvAccess/channelLocal.cpp +++ b/src/pvAccess/channelLocal.cpp @@ -1014,10 +1014,22 @@ void ChannelArrayLocal::putArray( void ChannelArrayLocal::getLength() { - channelArrayRequester->getLengthDone( - Status::Ok,getPtrSelf(), - pvArray->getLength(), - pvArray->getCapacity()); + size_t length = 0; + size_t capacity = 0; + const char *exceptionMessage = NULL; + pvRecord->lock(); + try { + length = pvArray->getLength(); + capacity = pvArray->getCapacity(); + } catch(std::exception e) { + exceptionMessage = e.what(); + } + pvRecord->unlock(); + Status status = Status::Ok; + if(exceptionMessage!=NULL) { + status = Status(Status::Status::STATUSTYPE_ERROR,exceptionMessage); + } + channelArrayRequester->getLengthDone(status,getPtrSelf(),length,capacity); } void ChannelArrayLocal::setLength(size_t length, size_t capacity)