summaryrefslogtreecommitdiff
path: root/cpp/src/tests/Cluster.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-07-23 13:08:16 +0000
committerAlan Conway <aconway@apache.org>2007-07-23 13:08:16 +0000
commit1a469b992ef2f28d98f43e63cf4d520c1bf830a4 (patch)
treec743052e2d2ab10a28960234e3efd3534cdb14c1 /cpp/src/tests/Cluster.h
parent4ab144d3d0a48a4abc1814e3244ef830344f19b2 (diff)
downloadqpid-python-1a469b992ef2f28d98f43e63cf4d520c1bf830a4.tar.gz
* src/tests/cluster.mk: Enable cluster test.
* src/tests/Cluster.h (class TestHandler): Fixed race in TestHandler::waitFor * src/tests/Cluster.cpp - Allow separate start of parent and child processes. * src/qpid/Options.cpp (parse): Skip argv parsing if argc=0. * src/qpid/cluster/Cluster.cpp (configChange): assert group name. * src/qpid/cluster/Cpg.cpp, .h: Additional logging * src/qpid/framing/AMQFrame.cpp: Initialize all fields in ctor, avoid valgrind warning. * src/qpid/log/Logger.cpp: Initialize singleton automatically from environment so logging can be used on tests. * src/qpid/sys/Time.h: Avoid overflow in AbsTime(t, TIME_INFINITE) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@558710 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Cluster.h')
-rw-r--r--cpp/src/tests/Cluster.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpp/src/tests/Cluster.h b/cpp/src/tests/Cluster.h
index bf6d1c2a64..c2909e0c1b 100644
--- a/cpp/src/tests/Cluster.h
+++ b/cpp/src/tests/Cluster.h
@@ -48,20 +48,25 @@ using namespace boost;
void null_deleter(void*) {}
template <class T>
-struct TestHandler : public Handler<T&>, public vector<T>, public Monitor
+class TestHandler : public Handler<T&>, public vector<T>
{
+ Monitor lock;
+
+ public:
void handle(T& frame) {
- Mutex::ScopedLock l(*this);
+ Mutex::ScopedLock l(lock);
push_back(frame);
- notifyAll();
+ BOOST_MESSAGE(getpid()<<" TestHandler::handle: " << this->size());
+ lock.notifyAll();
}
bool waitFor(size_t n) {
- Mutex::ScopedLock l(*this);
- AbsTime deadline(now(), 5*TIME_SEC);
- while (vector<T>::size() != n && wait(deadline))
+ Mutex::ScopedLock l(lock);
+ BOOST_MESSAGE(getpid()<<" TestHandler::waitFor("<<n<<") "<<this->size());
+ AbsTime deadline(now(), 2*TIME_SEC);
+ while (vector<T>::size() < n && lock.wait(deadline))
;
- return vector<T>::size() == n;
+ return vector<T>::size() >= n;
}
};