summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-09-24 21:15:46 +0000
committerAlan Conway <aconway@apache.org>2007-09-24 21:15:46 +0000
commitb3992a21f76f38797723f70168ecda6be21e3719 (patch)
tree9654292603c8b2bc31d5685e8f965b4713352f72 /cpp/src
parent96c24e0cd7359cfb2fb026c742cbd1b2d23a0015 (diff)
downloadqpid-python-b3992a21f76f38797723f70168ecda6be21e3719.tar.gz
2007-09-24 Alan Conway <aconway@redhat.com>
* cpp/src/qpid/broker/SessionManager.cpp: Manage suspended sessions. Replaces SuspendedSessions. * cpp/src/qpid/broker/SessionState.cpp: Work with SessionManager. * cpp/src/qpid/broker/SessionHandler.cpp: Owns SessionState. * cpp/src/qpid/broker/Connection.h, .cpp: Owns session handlers. * cpp/src/qpid/broker/Broker.h: Added SessionManager member. * cpp/src/Makefile.am: Added broker/SessionManager.cpp * amqp.0-10-preview.xml: Added session-busy and channel-busy constants. * cpp/src/tests/.valgrind.supp-default: Added suppresssions for F7. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@578975 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Makefile.am2
-rw-r--r--cpp/src/qpid/broker/Broker.h4
-rw-r--r--cpp/src/qpid/broker/Connection.cpp9
-rw-r--r--cpp/src/qpid/broker/Connection.h6
-rw-r--r--cpp/src/qpid/broker/SessionHandler.cpp12
-rw-r--r--cpp/src/qpid/broker/SessionHandler.h9
-rw-r--r--cpp/src/qpid/broker/SessionManager.cpp84
-rw-r--r--cpp/src/qpid/broker/SessionManager.h83
-rw-r--r--cpp/src/qpid/broker/SessionState.cpp15
-rw-r--r--cpp/src/qpid/broker/SessionState.h18
-rw-r--r--cpp/src/qpid/broker/SuspendedSessions.cpp60
-rw-r--r--cpp/src/qpid/broker/SuspendedSessions.h61
-rw-r--r--cpp/src/tests/.valgrind.supp-default18
-rw-r--r--cpp/src/tests/ClientSessionTest.cpp3
-rw-r--r--cpp/src/tests/Session.cpp63
-rwxr-xr-xcpp/src/tests/run_test1
16 files changed, 234 insertions, 214 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index b0156e754e..e70b4d5a1b 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -177,6 +177,8 @@ libqpidbroker_la_SOURCES = \
qpid/broker/SemanticState.cpp \
qpid/broker/SessionState.h \
qpid/broker/SessionState.cpp \
+ qpid/broker/SessionManager.h \
+ qpid/broker/SessionManager.cpp \
qpid/broker/SessionHandler.h \
qpid/broker/SessionHandler.cpp \
qpid/broker/SemanticHandler.cpp \
diff --git a/cpp/src/qpid/broker/Broker.h b/cpp/src/qpid/broker/Broker.h
index 1ccc3564f5..acb059451a 100644
--- a/cpp/src/qpid/broker/Broker.h
+++ b/cpp/src/qpid/broker/Broker.h
@@ -29,6 +29,7 @@
#include "ExchangeRegistry.h"
#include "MessageStore.h"
#include "QueueRegistry.h"
+#include "SessionManager.h"
#include "qpid/Options.h"
#include "qpid/Plugin.h"
#include "qpid/Url.h"
@@ -103,6 +104,8 @@ class Broker : public sys::Runnable, public Plugin::Target
uint64_t getStagingThreshold() { return stagingThreshold; }
DtxManager& getDtxManager() { return dtxManager; }
+ SessionManager& getSessionManager() { return sessionManager; }
+
private:
sys::Acceptor& getAcceptor() const;
@@ -117,6 +120,7 @@ class Broker : public sys::Runnable, public Plugin::Target
ConnectionFactory factory;
DtxManager dtxManager;
HandlerUpdaters handlerUpdaters;
+ SessionManager sessionManager;
static MessageStore* createStore(const Options& config);
};
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp
index b1b8abe4fd..a21db0f603 100644
--- a/cpp/src/qpid/broker/Connection.cpp
+++ b/cpp/src/qpid/broker/Connection.cpp
@@ -94,13 +94,12 @@ void Connection::closeChannel(uint16_t id) {
}
SessionHandler& Connection::getChannel(ChannelId id) {
- boost::optional<SessionHandler>& ch = channels[id];
- if (!ch) {
- ch = boost::in_place(boost::ref(*this), id);
+ ChannelMap::iterator i=channels.find(id);
+ if (i == channels.end()) {
+ i = channels.insert(id, new SessionHandler(*this, id)).first;
}
- return *ch;
+ return *i;
}
-
}}
diff --git a/cpp/src/qpid/broker/Connection.h b/cpp/src/qpid/broker/Connection.h
index 4f64873dc3..11f5545144 100644
--- a/cpp/src/qpid/broker/Connection.h
+++ b/cpp/src/qpid/broker/Connection.h
@@ -38,7 +38,7 @@
#include "ConnectionHandler.h"
#include "SessionHandler.h"
-#include <boost/optional.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
namespace qpid {
namespace broker {
@@ -82,9 +82,7 @@ class Connection : public sys::ConnectionInputHandler,
void closeChannel(framing::ChannelId channel);
private:
-
- // Use boost::optional to allow default-constructed uninitialized entries in the map.
- typedef std::map<framing::ChannelId, boost::optional<SessionHandler> >ChannelMap;
+ typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
framing::ProtocolVersion version;
diff --git a/cpp/src/qpid/broker/SessionHandler.cpp b/cpp/src/qpid/broker/SessionHandler.cpp
index 13e5c247be..ecbffed465 100644
--- a/cpp/src/qpid/broker/SessionHandler.cpp
+++ b/cpp/src/qpid/broker/SessionHandler.cpp
@@ -35,7 +35,7 @@ SessionHandler::SessionHandler(Connection& c, ChannelId ch)
connection(c), channel(ch), proxy(out),
ignoring(false) {}
-SessionHandler::~SessionHandler() {}
+SessionHandler::~SessionHandler() { }
namespace {
ClassId classId(AMQMethodBody* m) { return m ? m->amqpMethodId() : 0; }
@@ -53,7 +53,7 @@ void SessionHandler::handleIn(AMQFrame& f) {
try {
if (m && m->invoke(this))
return;
- else if (session)
+ else if (session.get())
session->in(f);
else if (!ignoring)
throw ChannelErrorException(
@@ -76,7 +76,7 @@ void SessionHandler::handleOut(AMQFrame& f) {
}
void SessionHandler::assertOpen(const char* method) {
- if (!session)
+ if (!session.get())
throw ChannelErrorException(
QPID_MSG(""<<method<<" failed: No session for channel "
<< getChannel()));
@@ -85,7 +85,7 @@ void SessionHandler::assertOpen(const char* method) {
void SessionHandler::assertClosed(const char* method) {
// FIXME aconway 2007-08-31: Should raise channel-busy, need
// to update spec.
- if (session)
+ if (session.get())
throw PreconditionFailedException(
QPID_MSG(""<<method<<" failed: "
<< channel << " already open on channel "
@@ -94,7 +94,9 @@ void SessionHandler::assertClosed(const char* method) {
void SessionHandler::open(uint32_t detachedLifetime) {
assertClosed("open");
- session.reset(new SessionState(*this, detachedLifetime));
+ std::auto_ptr<SessionState> state(
+ connection.broker.getSessionManager().open(*this, detachedLifetime));
+ session.reset(state.release());
getProxy().getSession().attached(session->getId(), session->getTimeout());
}
diff --git a/cpp/src/qpid/broker/SessionHandler.h b/cpp/src/qpid/broker/SessionHandler.h
index 5ae5b5cfee..aec3731dc0 100644
--- a/cpp/src/qpid/broker/SessionHandler.h
+++ b/cpp/src/qpid/broker/SessionHandler.h
@@ -27,6 +27,8 @@
#include "qpid/framing/AMQP_ClientProxy.h"
#include "qpid/framing/amqp_types.h"
+#include <boost/noncopyable.hpp>
+
namespace qpid {
namespace broker {
@@ -37,11 +39,10 @@ class SessionState;
* A SessionHandler is associated with each active channel. It
* receives incoming frames, handles session commands and manages the
* association between the channel and a session.
- *
- * SessionHandlers can be stored in a map by value.
*/
class SessionHandler : public framing::FrameHandler::InOutHandler,
- private framing::AMQP_ServerOperations::SessionHandler
+ private framing::AMQP_ServerOperations::SessionHandler,
+ private boost::noncopyable
{
public:
SessionHandler(Connection&, framing::ChannelId);
@@ -84,8 +85,8 @@ class SessionHandler : public framing::FrameHandler::InOutHandler,
Connection& connection;
const framing::ChannelId channel;
framing::AMQP_ClientProxy proxy;
- shared_ptr<SessionState> session;
bool ignoring;
+ std::auto_ptr<SessionState> session;
};
}} // namespace qpid::broker
diff --git a/cpp/src/qpid/broker/SessionManager.cpp b/cpp/src/qpid/broker/SessionManager.cpp
new file mode 100644
index 0000000000..20dd29bc31
--- /dev/null
+++ b/cpp/src/qpid/broker/SessionManager.cpp
@@ -0,0 +1,84 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "SessionManager.h"
+#include "SessionState.h"
+#include "qpid/framing/reply_exceptions.h"
+#include "qpid/memory.h"
+
+#include <boost/bind.hpp>
+
+#include <algorithm>
+#include <functional>
+
+namespace qpid {
+namespace broker {
+
+using namespace sys;
+using namespace framing;
+using std::make_pair;
+
+SessionManager::SessionManager() {}
+
+SessionManager::~SessionManager() {}
+
+std::auto_ptr<SessionState> SessionManager::open(
+ SessionHandler& h, uint32_t timeout_)
+{
+ Mutex::ScopedLock l(lock);
+ std::auto_ptr<SessionState> session(new SessionState(*this, h, timeout_));
+ active.insert(session->getId());
+ return session;
+}
+
+void SessionManager::suspend(std::auto_ptr<SessionState> session) {
+ Mutex::ScopedLock l(lock);
+ session->expiry = AbsTime(now(),session->getTimeout());
+ suspended.push_back(session.release()); // In expiry order
+ eraseExpired();
+}
+
+std::auto_ptr<SessionState> SessionManager::resume(const Uuid& id) {
+ Mutex::ScopedLock l(lock);
+ eraseExpired();
+ if (active.find(id) != active.end())
+ throw SessionBusyException(
+ QPID_MSG("Session already active: " << id));
+ Suspended::iterator i = std::find_if(
+ suspended.begin(), suspended.end(),
+ boost::bind(std::equal_to<Uuid>(), id, boost::bind(&SessionState::getId, _1))
+ );
+ if (i == suspended.end())
+ throw InvalidArgumentException(
+ QPID_MSG("No suspended session with id=" << id));
+ active.insert(id);
+ return make_auto_ptr(suspended.release(i).release());
+}
+
+void SessionManager::eraseExpired() {
+ // Called with lock held.
+ Suspended::iterator i = std::lower_bound(
+ suspended.begin(), suspended.end(), now(),
+ boost::bind(std::less<AbsTime>(), boost::bind(&SessionState::expiry, _1), _2));
+ suspended.erase(suspended.begin(), i);
+}
+
+}} // namespace qpid::broker
diff --git a/cpp/src/qpid/broker/SessionManager.h b/cpp/src/qpid/broker/SessionManager.h
new file mode 100644
index 0000000000..8225f04798
--- /dev/null
+++ b/cpp/src/qpid/broker/SessionManager.h
@@ -0,0 +1,83 @@
+#ifndef QPID_BROKER_SESSIONMANAGER_H
+#define QPID_BROKER_SESSIONMANAGER_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include <qpid/framing/Uuid.h>
+#include <qpid/sys/Time.h>
+#include <qpid/sys/Mutex.h>
+
+#include <boost/noncopyable.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <set>
+#include <vector>
+#include <memory>
+
+namespace qpid {
+namespace broker {
+
+class SessionState;
+class SessionHandler;
+
+/**
+ * Create and manage SessionState objects.
+ */
+class SessionManager : private boost::noncopyable {
+ public:
+ SessionManager();
+ ~SessionManager();
+ /** Open a new active session, caller takes ownership */
+ std::auto_ptr<SessionState> open(
+ SessionHandler& h, uint32_t timeout_);
+
+ /** Suspend a session, start it's timeout counter.
+ * The factory takes ownership.
+ */
+ void suspend(std::auto_ptr<SessionState> session);
+
+ /** Resume a suspended session.
+ *@throw Exception if timed out or non-existant.
+ */
+ std::auto_ptr<SessionState> resume(const framing::Uuid& id);
+
+ private:
+ typedef boost::ptr_vector<SessionState> Suspended;
+ typedef std::set<framing::Uuid> Active;
+
+ sys::Mutex lock;
+ Suspended suspended;
+ Active active;
+
+ void eraseExpired();
+ friend class SessionState; // removes deleted sessions from active set.
+};
+
+
+
+}} // namespace qpid::broker
+
+
+
+
+
+#endif /*!QPID_BROKER_SESSIONMANAGER_H*/
diff --git a/cpp/src/qpid/broker/SessionState.cpp b/cpp/src/qpid/broker/SessionState.cpp
index acfb3bfea8..b56aa106a3 100644
--- a/cpp/src/qpid/broker/SessionState.cpp
+++ b/cpp/src/qpid/broker/SessionState.cpp
@@ -19,18 +19,20 @@
*
*/
#include "SessionState.h"
+#include "SessionManager.h"
#include "SessionHandler.h"
#include "Connection.h"
#include "Broker.h"
#include "SemanticHandler.h"
+#include "qpid/framing/reply_exceptions.h"
namespace qpid {
namespace broker {
using namespace framing;
-SessionState::SessionState(SessionHandler& h, uint32_t timeout_)
- : handler(&h), id(true), timeout(timeout_),
+SessionState::SessionState(SessionManager& f, SessionHandler& h, uint32_t timeout_)
+ : factory(f), handler(&h), id(true), timeout(timeout_),
broker(h.getConnection().broker),
version(h.getConnection().getVersion())
{
@@ -45,6 +47,11 @@ SessionState::SessionState(SessionHandler& h, uint32_t timeout_)
broker.update(handler->getChannel(), *this);
}
+SessionState::~SessionState() {
+ // Remove ID from active session list.
+ factory.active.erase(getId());
+}
+
SessionHandler& SessionState::getHandler() {
assert(isAttached());
return *handler;
@@ -53,9 +60,7 @@ SessionHandler& SessionState::getHandler() {
AMQP_ClientProxy& SessionState::getProxy() {
return getHandler().getProxy();
}
- /** Convenience for: getHandler()->getConnection()
- *@pre getHandler() != 0
- */
+
Connection& SessionState::getConnection() {
return getHandler().getConnection();
}
diff --git a/cpp/src/qpid/broker/SessionState.h b/cpp/src/qpid/broker/SessionState.h
index 1334cc7005..58944c5968 100644
--- a/cpp/src/qpid/broker/SessionState.h
+++ b/cpp/src/qpid/broker/SessionState.h
@@ -25,10 +25,13 @@
#include "qpid/framing/Uuid.h"
#include "qpid/framing/FrameHandler.h"
#include "qpid/framing/ProtocolVersion.h"
+#include "qpid/sys/Time.h"
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
+#include <set>
+#include <vector>
namespace qpid {
@@ -39,6 +42,7 @@ class AMQP_ClientProxy;
namespace broker {
class SessionHandler;
+class SessionManager;
class Broker;
class Connection;
@@ -59,9 +63,7 @@ class SessionState : public framing::FrameHandler::Chains,
private boost::noncopyable
{
public:
- /** SessionState for a newly opened connection. */
- SessionState(SessionHandler& h, uint32_t timeout_);
-
+ ~SessionState();
bool isAttached() { return handler; }
/** @pre isAttached() */
@@ -77,19 +79,21 @@ class SessionState : public framing::FrameHandler::Chains,
uint32_t getTimeout() const { return timeout; }
Broker& getBroker() { return broker; }
framing::ProtocolVersion getVersion() const { return version; }
-
private:
- friend class SessionHandler; // Only SessionHandler can attach/detach
- void detach() { handler=0; }
- void attach(SessionHandler& h) { handler = &h; }
+ /** Only SessionManager can open sessions */
+ SessionState(SessionManager& f, SessionHandler& h, uint32_t timeout_);
+ SessionManager& factory;
SessionHandler* handler;
framing::Uuid id;
uint32_t timeout;
+ sys::AbsTime expiry; // Used by SessionManager.
Broker& broker;
boost::ptr_vector<framing::FrameHandler> chain;
framing::ProtocolVersion version;
+
+ friend class SessionManager;
};
}} // namespace qpid::broker
diff --git a/cpp/src/qpid/broker/SuspendedSessions.cpp b/cpp/src/qpid/broker/SuspendedSessions.cpp
deleted file mode 100644
index 1cd0710f1e..0000000000
--- a/cpp/src/qpid/broker/SuspendedSessions.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include "SuspendedSessions.h"
-#include <boost/bind.hpp>
-
-namespace qpid {
-namespace broker {
-
-using namespace framing;
-using namespace sys;
-using namespace boost;
-typedef Mutex::ScopedLock Lock;
-
-void SuspendedSessions::suspend(SessionState& s) {
- Lock l(lock);
- assert(s.state == SessionState::ACTIVE);
- if (s.timeout == 0)
- s.state = SessionState::CLOSED;
- else {
- AbsTime expires(now(), Duration(s.timeout*TIME_SEC));
- suspended.insert(std::make_pair(expires, s));
- s.state = SessionState::SUSPENDED;
- }
-}
-
-SessionState SuspendedSessions::resume(const Uuid& id)
-{
- Lock l(lock);
- Map::iterator notExpired = suspended.lower_bound(now());
- suspended.erase(suspended.begin(), notExpired);
- Map::iterator i = suspended.begin();
- while (i != suspended.end() && i->second.getId() != id)
- ++i;
- if (i == suspended.end())
- throw Exception(QPID_MSG("Session timed out or invalid ID: " << id));
- return i->second;
-}
-
-}} // namespace qpid::broker
-
-
-
diff --git a/cpp/src/qpid/broker/SuspendedSessions.h b/cpp/src/qpid/broker/SuspendedSessions.h
deleted file mode 100644
index d3a0c17050..0000000000
--- a/cpp/src/qpid/broker/SuspendedSessions.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef QPID_BROKER_SUSPENDEDSESSIONS_H
-#define QPID_BROKER_SUSPENDEDSESSIONS_H
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "qpid/broker/SessionState.h"
-#include "qpid/sys/Time.h"
-#include "qpid/sys/Mutex.h"
-
-#include <map>
-
-namespace qpid {
-namespace broker {
-
-/**
- * Thread safe collection of suspended sessions.
- * Every session is owned either by a connection's SessionHandler
- * or by the SuspendedSessions.
- */
-class SuspendedSessions {
- typedef std::multimap<sys::AbsTime,SessionState> Map;
-
- sys::Mutex lock;
- Map suspended;
-
- public:
- /** Suspend a session, start it's timeout counter.*/
- void suspend(SessionState& session);
-
- /** Resume a suspended session.
- *@throw Exception if timed out or non-existant.
- */
- SessionState resume(const framing::Uuid& id);
-};
-
-
-
-}} // namespace qpid::broker
-
-
-
-#endif /*!QPID_BROKER_SUSPENDEDSESSIONS_H*/
diff --git a/cpp/src/tests/.valgrind.supp-default b/cpp/src/tests/.valgrind.supp-default
index 4136e53381..decac01aeb 100644
--- a/cpp/src/tests/.valgrind.supp-default
+++ b/cpp/src/tests/.valgrind.supp-default
@@ -42,4 +42,22 @@
fun:pthread_create@GLIBC_2.0
fun:_ZN4qpid3sys16AsynchIOAcceptor3runEPNS0_29ConnectionInputHandlerFactoryE
}
+
+{
+ Bogus error appearing on Fedora 7.
+ Memcheck:Cond
+ fun:_dl_relocate_object
+ fun:dl_main
+ fun:_dl_sysdep_start
+ fun:_dl_start
+ obj:/lib/ld-2.6.so
+}
+{
+ Bogus error appearing on Fedora 7.
+ Memcheck:Cond
+ fun:_dl_relocate_object
+ fun:dl_open_worker
+ fun:_dl_catch_error
+ fun:_dl_open
+}
diff --git a/cpp/src/tests/ClientSessionTest.cpp b/cpp/src/tests/ClientSessionTest.cpp
index 12b50485e4..1d59fbed33 100644
--- a/cpp/src/tests/ClientSessionTest.cpp
+++ b/cpp/src/tests/ClientSessionTest.cpp
@@ -137,6 +137,9 @@ public:
listener.messages.pop_front();
}
+
+ void testSuspendResume() {
+ }
};
// Make this test suite a plugin.
diff --git a/cpp/src/tests/Session.cpp b/cpp/src/tests/Session.cpp
deleted file mode 100644
index e33ec6e50c..0000000000
--- a/cpp/src/tests/Session.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "qpid/broker/SuspendedSessions.h"
-
-#define BOOST_AUTO_TEST_MAIN
-#include <boost/test/auto_unit_test.hpp>
-
-using namespace std;
-using namespace qpid::framing;
-using namespace qpid::broker;
-using namespace qpid::sys;
-
-BOOST_AUTO_TEST_CASE(testSuspendedSessions) {
- SuspendedSessions suspended;
-
- SessionState s;
- BOOST_CHECK_EQUAL(s.getState(), SessionState::CLOSED);
- s.open(0);
- BOOST_CHECK_EQUAL(s.getState(), SessionState::ACTIVE);
- BOOST_CHECK(!s.getId().empty());
- suspended.suspend(s);
- BOOST_CHECK(s.getState() == SessionState::CLOSED);
- try {
- s = suspended.resume(s.getId());
- BOOST_FAIL("Expected session to be timed out.");
- } catch (...) {}
-
- s.close();
- s.open(1); // New session, 1 sec timeout.
- try {
- suspended.resume(s.getId());
- BOOST_FAIL("Expeced exception: non-existent session.");
- } catch (...) {}
- suspended.suspend(s);
- BOOST_CHECK(s.getState() == SessionState::SUSPENDED);
- s = suspended.resume(s.getId());
- BOOST_CHECK(s.getState() == SessionState::ACTIVE);
-
- suspended.suspend(s); // Real timeout
- sleep(2);
- try {
- suspended.resume(s.getId());
- BOOST_FAIL("Expeced timeout.");
- } catch (...) {}
-}
-
-
diff --git a/cpp/src/tests/run_test b/cpp/src/tests/run_test
index d717cd2ace..615e8132f1 100755
--- a/cpp/src/tests/run_test
+++ b/cpp/src/tests/run_test
@@ -36,6 +36,7 @@ if grep -l "^# Generated by .*libtool" "$1" >/dev/null 2>&1; then
test -n "$VALGRIND" && vg_check
else
# This is a non-libtool shell script, just execute it.
+ export VALGRIND srcdir
exec "$@"
fi