From d0200d8d9999d2ae54483e5fc85c1315ba0a56c3 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 15 Oct 2014 16:20:07 +0200 Subject: [PATCH 1/4] Added tag 4.0.0 for changeset 84ef9a50bcca --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 1d77148..a5b3dd5 100644 --- a/.hgtags +++ b/.hgtags @@ -20,3 +20,5 @@ ceca448e7c62c23388a0c866c905c7080633a875 4.0.0 cf6fc9696904fd1735523a70a4f59b5ad6a3f2d5 4.0.0 cf6fc9696904fd1735523a70a4f59b5ad6a3f2d5 4.0.0 91b7272415af8fdb5b81c98cc6c374558d2ab805 4.0.0 +91b7272415af8fdb5b81c98cc6c374558d2ab805 4.0.0 +84ef9a50bccaf7fcd1aef1b3a5d0cd6336fdac4c 4.0.0 From 846fc36bc86f50a85789016257c02bc16acc845e Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 15 Oct 2014 19:15:58 +0200 Subject: [PATCH 2/4] Added tag 4.0.0 for changeset c6df866bf6ca --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index a5b3dd5..07a3bed 100644 --- a/.hgtags +++ b/.hgtags @@ -22,3 +22,5 @@ cf6fc9696904fd1735523a70a4f59b5ad6a3f2d5 4.0.0 91b7272415af8fdb5b81c98cc6c374558d2ab805 4.0.0 91b7272415af8fdb5b81c98cc6c374558d2ab805 4.0.0 84ef9a50bccaf7fcd1aef1b3a5d0cd6336fdac4c 4.0.0 +84ef9a50bccaf7fcd1aef1b3a5d0cd6336fdac4c 4.0.0 +c6df866bf6ca8f9385c91dd74b65fea34bab58ca 4.0.0 From 5c17b563b71e779cef519676659f2d0e5c307e9c Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Thu, 16 Oct 2014 10:09:04 +0200 Subject: [PATCH 3/4] fixed stress tests --- testApp/remote/channelAccessIFTest.cpp | 10 ++++-- testApp/remote/syncTestRequesters.h | 44 ++++++++++++++++++-------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 740449e..7f90f0a 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -2119,6 +2119,12 @@ void ChannelAccessIFTest::test_stressPutAndGetLargeArray() { return; } + bool s = putReq->syncGet(getTimeoutSec()); + if (!s) { + testFail("%s: sync get failed", CURRENT_FUNCTION); + return; + } + PVDoubleArray::shared_pointer value = putReq->getPVStructure()->getSubField("value"); if (!value.get()) { testFail("%s: getting double array value field failed ", CURRENT_FUNCTION); @@ -2297,9 +2303,7 @@ void ChannelAccessIFTest::test_stressMonitorAndProcess() { return; } - while(monitorReq->getMonitorCounter() < i) { - monitorReq->waitUntilMonitor(getTimeoutSec()); - } + monitorReq->waitUntilMonitor(i, getTimeoutSec()); int counter = monitorReq->getMonitorCounter(); diff --git a/testApp/remote/syncTestRequesters.h b/testApp/remote/syncTestRequesters.h index 8a4ae56..68b1e6d 100755 --- a/testApp/remote/syncTestRequesters.h +++ b/testApp/remote/syncTestRequesters.h @@ -48,7 +48,7 @@ class SyncBaseRequester { SyncBaseRequester(bool debug = false): m_debug(debug), - m_event(new Event()), + m_event(), m_connectedStatus(false), m_getStatus(false), m_putStatus(false) {} @@ -126,25 +126,17 @@ class SyncBaseRequester { } void resetEvent() { - Lock lock(m_eventMutex); - m_event.reset(new Event()); + m_event.tryWait(); } void signalEvent() { - Lock lock(m_eventMutex); - m_event->signal(); + m_event.signal(); } bool waitUntilEvent(double timeOut) { - std::tr1::shared_ptr event; - { - Lock lock(m_eventMutex); - event = m_event; - } - - bool signaled = event->wait(timeOut); + bool signaled = m_event.wait(timeOut); if (!signaled) { if (m_debug) @@ -158,7 +150,7 @@ class SyncBaseRequester { private: - std::tr1::shared_ptr m_event; + epics::pvData::Event m_event; bool m_connectedStatus; bool m_getStatus; bool m_putStatus; @@ -167,7 +159,6 @@ class SyncBaseRequester { Mutex m_getStatusMutex; Mutex m_putStatusMutex; Mutex m_processStatusMutex; - Mutex m_eventMutex; }; @@ -1136,6 +1127,31 @@ class SyncMonitorRequesterImpl: public MonitorRequester, public SyncBaseRequeste return m_monitorStatus; } + bool waitUntilMonitor(int expectedCount, double timeOut) + { + + resetEvent(); + + { + Lock lock(m_pointerMutex); + m_monitorStatus = false; + if (m_monitorCounter >= expectedCount) + return true; + } + + + bool signaled = waitUntilEvent(timeOut); + if (!signaled) { + + if (m_debug) + std::cerr << getRequesterName() << ".waitUntilMonitor:" << " timeout occurred" << endl; + + return false; + } + + Lock lock(m_pointerMutex); + return m_monitorStatus; + } virtual string getRequesterName() { From bccddcc41837ed809b79a3189b0edfa0f448e479 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Thu, 16 Oct 2014 11:11:24 +0200 Subject: [PATCH 4/4] cyclic ref (memory leak) fixed when request are left on sendQueue --- src/remote/codec.cpp | 3 +++ src/remote/codec.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index cffe3fe..67bb701 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -1138,6 +1138,9 @@ namespace epics { // clean resources internalClose(true); + // this is important to avoid cyclic refs (memory leak) + clearSendQueue(); + _sendQueue.wakeup(); // post close diff --git a/src/remote/codec.h b/src/remote/codec.h index 3c36f54..9bfa24f 100644 --- a/src/remote/codec.h +++ b/src/remote/codec.h @@ -168,6 +168,11 @@ namespace epics { } } + size_t size() { + epics::pvData::Lock lock(_queueMutex); + return _queue.size(); + } + private: std::deque _queue;