From 40ecc93e9d2d6496bc0f2aeaf2b81836f268cfa3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 4 Apr 2018 09:46:25 -0700 Subject: [PATCH] client context: use mutex guards whether this locking is necessary is another question... --- src/remoteClient/clientContextImpl.cpp | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index 2c64e3b..bdcb36c 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include @@ -915,6 +917,7 @@ public: } } + // TODO: m_structure and m_bitSet guarded by m_structureMutex? (as below) if (!(*m_structure->getStructure() == *pvPutStructure->getStructure())) { EXCEPTION_GUARD3(m_callback, cb, cb->putDone(invalidPutStructureStatus, thisPtr)); @@ -933,10 +936,11 @@ public: } try { - lock(); - *m_bitSet = *pvPutBitSet; - m_structure->copyUnchecked(*pvPutStructure, *m_bitSet); - unlock(); + { + epicsGuard G(*this); + *m_bitSet = *pvPutBitSet; + m_structure->copyUnchecked(*pvPutStructure, *m_bitSet); + } m_channel->checkAndGetTransport()->enqueueSendRequest(internal_from_this()); } catch (std::runtime_error &rte) { abortRequest(); @@ -1182,10 +1186,11 @@ public: } try { - lock(); - *m_putDataBitSet = *bitSet; - m_putData->copyUnchecked(*pvPutStructure, *m_putDataBitSet); - unlock(); + { + epicsGuard G(*this); + *m_putDataBitSet = *bitSet; + m_putData->copyUnchecked(*pvPutStructure, *m_putDataBitSet); + } m_channel->checkAndGetTransport()->enqueueSendRequest(internal_from_this()); } catch (std::runtime_error &rte) { abortRequest(); @@ -1420,9 +1425,10 @@ public: } try { - m_structureMutex.lock(); - m_structure = pvArgument; - m_structureMutex.unlock(); + { + epicsGuard G(m_structureMutex); + m_structure = pvArgument; + } m_channel->checkAndGetTransport()->enqueueSendRequest(internal_from_this()); } catch (std::runtime_error &rte) {