From ec973ce00dff5e03818e3046e54b4aa60b4ac424 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 27 Mar 2014 18:08:02 -0500 Subject: [PATCH 1/6] Fix link library order for testCodec --- testApp/remote/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testApp/remote/Makefile b/testApp/remote/Makefile index e448fa3..3dc2a39 100644 --- a/testApp/remote/Makefile +++ b/testApp/remote/Makefile @@ -53,8 +53,8 @@ TESTS += testChannelAccess TESTPROD_HOST += testCodec testCodec_SRCS = testCodec -testCodec_LIBS += pvData pvAccess pvMB Com -TESTS += testCodec +testCodec_LIBS += pvAccess pvData pvMB Com +TESTS += testCodec PROD_HOST += pvget From 8754ac5336e1ac01ac022a29b31b14e6fdac288a Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Mon, 31 Mar 2014 10:58:10 +0200 Subject: [PATCH 2/6] testChannelAccess: added stdout debug output to diagnose a failing test --- testApp/remote/channelAccessIFTest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index cdd1307..b3e7ae6 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -1698,9 +1698,13 @@ void ChannelAccessIFTest::test_channelMonitor(int queueSize) { } - valueField = monitorReq->getPVStructure()->getSubField("value"); +std::cout << *previousValue << std::endl; +std::cout << *valueField << std::endl; +std::cout << *monitorReq->getPVStructure() << std::endl; +std::cout << std::endl; + testOk(valueField->equals(*previousValue.get()) == false , "%s: value field not equals to a previous value", CURRENT_FUNCTION); From 4d189ade16b2b32e6336e2b0902b64a40cd69ee7 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Mon, 31 Mar 2014 11:46:50 +0200 Subject: [PATCH 3/6] testChannelAccess: added testDiag debug output to diagnose a failing test --- testApp/remote/channelAccessIFTest.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index b3e7ae6..83c1e19 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -1700,10 +1700,11 @@ void ChannelAccessIFTest::test_channelMonitor(int queueSize) { valueField = monitorReq->getPVStructure()->getSubField("value"); -std::cout << *previousValue << std::endl; -std::cout << *valueField << std::endl; -std::cout << *monitorReq->getPVStructure() << std::endl; -std::cout << std::endl; +std::ostringstream oss; +oss << *previousValue << std::endl; +oss << *valueField << std::endl; +oss << *monitorReq->getPVStructure(); +testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); testOk(valueField->equals(*previousValue.get()) == false , "%s: value field not equals to a previous value", CURRENT_FUNCTION); From 4fad0d41501811170b28c42d1d3ddb74c416dedf Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Mon, 31 Mar 2014 12:53:48 +0200 Subject: [PATCH 4/6] testChannelAccess: more added testDiag debug output to diagnose a failing test --- testApp/remote/channelAccessIFTest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 83c1e19..23382c2 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -1666,6 +1666,10 @@ void ChannelAccessIFTest::test_channelMonitor(int queueSize) { std::tr1::shared_ptr valueField = monitorReq->getPVStructure()->getSubField("value"); std::tr1::shared_ptr previousValue = getPVDataCreate()->createPVField(valueField->getField()); +std::ostringstream oss; +oss << *monitorReq->getPVStructure(); +testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); + ConvertPtr convert = getConvert(); convert->copy(valueField, previousValue); @@ -1701,8 +1705,8 @@ void ChannelAccessIFTest::test_channelMonitor(int queueSize) { valueField = monitorReq->getPVStructure()->getSubField("value"); std::ostringstream oss; -oss << *previousValue << std::endl; -oss << *valueField << std::endl; +oss << "previous value : " << *previousValue << std::endl; +oss << "current value : " << *valueField << std::endl; oss << *monitorReq->getPVStructure(); testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); From c67be5632a64ec5b3184a8ae3c7e0cf348a9b922 Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Mon, 31 Mar 2014 14:33:29 +0200 Subject: [PATCH 5/6] testServer: monitor sync --- testApp/remote/testServer.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index 75ab021..d8bda17 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -1827,6 +1828,7 @@ private: String m_channelName; MonitorRequester::shared_pointer m_monitorRequester; PVStructure::shared_pointer m_pvStructure; + PVStructure::shared_pointer m_copy; BitSet::shared_pointer m_changedBitSet; BitSet::shared_pointer m_overrunBitSet; bool m_first; @@ -1843,6 +1845,7 @@ protected: PVStructure::shared_pointer const & pvStructure, PVStructure::shared_pointer const & pvRequest) : m_channelName(channelName), m_monitorRequester(monitorRequester), m_pvStructure(getRequestedStructure(pvStructure, pvRequest)), + m_copy(getPVDataCreate()->createPVStructure(m_pvStructure->getStructure())), m_changedBitSet(new BitSet(m_pvStructure->getNumberFields())), m_overrunBitSet(new BitSet(m_pvStructure->getNumberFields())), m_first(true), @@ -1854,7 +1857,7 @@ protected: m_changedBitSet->set(0); - m_thisPtr->pvStructurePtr = m_pvStructure; + m_thisPtr->pvStructurePtr = m_copy; m_thisPtr->changedBitSet = m_changedBitSet; m_thisPtr->overrunBitSet = m_overrunBitSet; } @@ -1880,14 +1883,24 @@ public: PVACCESS_REFCOUNT_MONITOR_DESTRUCT(mockMonitor); } + void copy() + { + { + lock(); + getConvert()->copyStructure(m_pvStructure, m_copy); + unlock(); + } + } virtual Status start() { - m_active.set(); - + copy(); + // first monitor Monitor::shared_pointer thisPtr = shared_from_this(); m_monitorRequester->monitorEvent(thisPtr); + m_active.set(); // set here not to have race condition on first monitor + return Status::Ok; } @@ -1901,10 +1914,13 @@ public: { if (m_active.get()) { + copy(); + { Lock xx(m_lock); m_count = 0; } + Monitor::shared_pointer thisPtr = shared_from_this(); m_monitorRequester->monitorEvent(thisPtr); } From b2254b3b45d927396548574b05b6ae730f91788f Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Tue, 1 Apr 2014 09:39:31 +0200 Subject: [PATCH 6/6] testServer: propery monitor queue impl. --- testApp/remote/channelAccessIFTest.cpp | 2 + testApp/remote/testServer.cpp | 65 ++++++++++++++++++++------ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/testApp/remote/channelAccessIFTest.cpp b/testApp/remote/channelAccessIFTest.cpp index 23382c2..b8fc61c 100755 --- a/testApp/remote/channelAccessIFTest.cpp +++ b/testApp/remote/channelAccessIFTest.cpp @@ -1667,6 +1667,7 @@ void ChannelAccessIFTest::test_channelMonitor(int queueSize) { std::tr1::shared_ptr previousValue = getPVDataCreate()->createPVField(valueField->getField()); std::ostringstream oss; +//oss << *monitorReq->getChangedBitSet() << std::endl; oss << *monitorReq->getPVStructure(); testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); @@ -1707,6 +1708,7 @@ testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); std::ostringstream oss; oss << "previous value : " << *previousValue << std::endl; oss << "current value : " << *valueField << std::endl; +//oss << "changed : " << *monitorReq->getChangedBitSet() << std::endl; oss << *monitorReq->getPVStructure(); testDiag("%s:\n%s", CURRENT_FUNCTION, oss.str().c_str()); diff --git a/testApp/remote/testServer.cpp b/testApp/remote/testServer.cpp index d8bda17..1f9fb87 100644 --- a/testApp/remote/testServer.cpp +++ b/testApp/remote/testServer.cpp @@ -1812,8 +1812,24 @@ public: } }; +#include +class TraceLog { + public: + + TraceLog(const std::string &method) : m_method(method) { + std::cout << "--> " << m_method << std::endl; + } + ~TraceLog() { + std::cout << "<-- " << m_method << std::endl; + } + + private: + std::string m_method; +} + +#define TRACE_METHOD() TraceLog trace(CURRENT_FUNCTION); @@ -1833,7 +1849,8 @@ private: BitSet::shared_pointer m_overrunBitSet; bool m_first; Mutex m_lock; - int m_count; + enum QueueState { MM_STATE_FULL, MM_STATE_TAKEN, MM_STATE_FREE }; + QueueState m_state ; AtomicBoolean m_active; @@ -1850,7 +1867,7 @@ protected: m_overrunBitSet(new BitSet(m_pvStructure->getNumberFields())), m_first(true), m_lock(), - m_count(0), + m_state(MM_STATE_FREE), m_thisPtr(new MonitorElement()) { PVACCESS_REFCOUNT_MONITOR_CONSTRUCT(mockMonitor); @@ -1892,8 +1909,14 @@ public: } } virtual Status start() - { - copy(); + { + //TRACE_METHOD(); + + { + Lock xx(m_lock); + m_state = MM_STATE_FULL; + copy(); + } // first monitor Monitor::shared_pointer thisPtr = shared_from_this(); @@ -1912,13 +1935,25 @@ public: virtual void structureChanged() { + //TRACE_METHOD(); + if (m_active.get()) { - copy(); - { - Lock xx(m_lock); - m_count = 0; + Lock xx(m_lock); + + if (m_state == MM_STATE_FULL || m_state == MM_STATE_TAKEN) // "queue" full + { + m_overrunBitSet->set(0); + copy(); + return; + } + else + { + m_overrunBitSet->clear(0); + m_state = MM_STATE_FULL; + copy(); + } } Monitor::shared_pointer thisPtr = shared_from_this(); @@ -1928,25 +1963,27 @@ public: virtual MonitorElement::shared_pointer poll() { + //TRACE_METHOD(); + Lock xx(m_lock); - if (m_count) + if (m_state != MM_STATE_FULL) { return m_nullMonitor; } else { - m_count++; + m_state = MM_STATE_TAKEN; return m_thisPtr; } } virtual void release(MonitorElement::shared_pointer const & /*monitorElement*/) { + //TRACE_METHOD(); + Lock xx(m_lock); - if (m_count) - { - m_count--; - } + if (m_state == MM_STATE_TAKEN) + m_state = MM_STATE_FREE; } virtual void destroy()