summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-06-22 17:57:58 +0000
committerAlan Conway <aconway@apache.org>2009-06-22 17:57:58 +0000
commit3e52cd743be669757707b1f7c556211f11458ea7 (patch)
tree5437aed13e2d1a9c788c9fbac22c2b8099837251 /cpp
parent160dfd1259052babfd5bbee9384670cebbc796ff (diff)
downloadqpid-python-3e52cd743be669757707b1f7c556211f11458ea7.tar.gz
Log an error only the first time a detached session is used, ignore after that.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@787332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/amqp_0_10/SessionHandler.cpp35
-rw-r--r--cpp/src/qpid/amqp_0_10/SessionHandler.h1
2 files changed, 21 insertions, 15 deletions
diff --git a/cpp/src/qpid/amqp_0_10/SessionHandler.cpp b/cpp/src/qpid/amqp_0_10/SessionHandler.cpp
index f927db09bb..f8ae81e5d1 100644
--- a/cpp/src/qpid/amqp_0_10/SessionHandler.cpp
+++ b/cpp/src/qpid/amqp_0_10/SessionHandler.cpp
@@ -34,7 +34,12 @@ namespace amqp_0_10 {
using namespace framing;
using namespace std;
-#define CHECK_ATTACHED(MSG) if (!getState()) throw NotAttachedException(QPID_MSG(MSG << ": channel " << channel.get() << " is not attached"))
+void SessionHandler::checkAttached() {
+ if (!getState()) {
+ ignoring = true;
+ throw NotAttachedException(QPID_MSG("Channel " << channel.get() << " is not attached"));
+ }
+}
SessionHandler::SessionHandler(FrameHandler* out, ChannelId ch)
: channel(ch, out), peer(channel), ignoring(false), sendReady(), receiveReady() {}
@@ -76,7 +81,7 @@ void SessionHandler::handleIn(AMQFrame& f) {
else if (isSessionControl(m))
invoke(*m);
else {
- CHECK_ATTACHED("receiving " << f);
+ checkAttached();
if (!receiveReady)
throw IllegalStateException(QPID_MSG(getState()->getId() << ": Not ready to receive data"));
if (!getState()->receiverRecord(f))
@@ -122,7 +127,7 @@ bool isCommand(const AMQFrame& f) {
} // namespace
void SessionHandler::handleOut(AMQFrame& f) {
- CHECK_ATTACHED("sending " << f);
+ checkAttached();
if (!sendReady)
throw IllegalStateException(QPID_MSG(getState()->getId() << ": Not ready to send data"));
getState()->senderRecord(f);
@@ -153,7 +158,7 @@ void SessionHandler::attach(const std::string& name_, bool force) {
}
#define CHECK_NAME(NAME, MSG) do { \
- CHECK_ATTACHED(MSG); \
+ checkAttached(); \
if (NAME != getState()->getId().getName()) \
throw InvalidArgumentException( \
QPID_MSG(MSG << ": incorrect session name: " << NAME \
@@ -186,18 +191,18 @@ void SessionHandler::handleDetach() {
}
void SessionHandler::requestTimeout(uint32_t t) {
- CHECK_ATTACHED("session.request-timeout");
+ checkAttached();
getState()->setTimeout(t);
peer.timeout(t);
}
void SessionHandler::timeout(uint32_t t) {
- CHECK_ATTACHED("session.request-timeout");
+ checkAttached();
getState()->setTimeout(t);
}
void SessionHandler::commandPoint(const SequenceNumber& id, uint64_t offset) {
- CHECK_ATTACHED("session.command-point");
+ checkAttached();
getState()->receiverSetCommandPoint(SessionPoint(id, offset));
if (!receiveReady) {
receiveReady = true;
@@ -206,7 +211,7 @@ void SessionHandler::commandPoint(const SequenceNumber& id, uint64_t offset) {
}
void SessionHandler::expected(const SequenceSet& commands, const Array& /*fragments*/) {
- CHECK_ATTACHED("session.expected");
+ checkAttached();
if (getState()->hasState()) { // Replay
if (commands.empty()) throw IllegalStateException(
QPID_MSG(getState()->getId() << ": has state but client is attaching as new session."));
@@ -222,14 +227,14 @@ void SessionHandler::expected(const SequenceSet& commands, const Array& /*fragme
}
void SessionHandler::confirmed(const SequenceSet& commands, const Array& /*fragments*/) {
- CHECK_ATTACHED("session.confirmed");
+ checkAttached();
// Ignore non-contiguous confirmations.
if (!commands.empty() && commands.front() >= getState()->senderGetReplayPoint())
getState()->senderConfirmed(commands.rangesBegin()->last());
}
void SessionHandler::completed(const SequenceSet& commands, bool timelyReply) {
- CHECK_ATTACHED("session.completed");
+ checkAttached();
getState()->senderCompleted(commands);
if (getState()->senderNeedKnownCompleted() || timelyReply) {
peer.knownCompleted(commands);
@@ -238,12 +243,12 @@ void SessionHandler::completed(const SequenceSet& commands, bool timelyReply) {
}
void SessionHandler::knownCompleted(const SequenceSet& commands) {
- CHECK_ATTACHED("session.known-completed");
+ checkAttached();
getState()->receiverKnownCompleted(commands);
}
void SessionHandler::flush(bool expected, bool confirmed, bool completed) {
- CHECK_ATTACHED("session.flush");
+ checkAttached();
if (expected) {
SequenceSet expectSet;
if (getState()->hasState())
@@ -267,13 +272,13 @@ void SessionHandler::gap(const SequenceSet& /*commands*/) {
void SessionHandler::sendDetach()
{
- CHECK_ATTACHED("session.sendDetach");
+ checkAttached();
ignoring = true;
peer.detach(getState()->getId().getName());
}
void SessionHandler::sendCompletion() {
- CHECK_ATTACHED("session.send-completion");
+ checkAttached();
const SequenceSet& c = getState()->receiverGetUnknownComplete();
peer.completed(c, getState()->receiverNeedKnownCompleted());
}
@@ -302,7 +307,7 @@ void SessionHandler::markReadyToSend() {
}
void SessionHandler::sendTimeout(uint32_t t) {
- CHECK_ATTACHED("session.send-timeout");
+ checkAttached();
peer.requestTimeout(t);
}
diff --git a/cpp/src/qpid/amqp_0_10/SessionHandler.h b/cpp/src/qpid/amqp_0_10/SessionHandler.h
index 0d9c72ff02..3ecc5e6141 100644
--- a/cpp/src/qpid/amqp_0_10/SessionHandler.h
+++ b/cpp/src/qpid/amqp_0_10/SessionHandler.h
@@ -107,6 +107,7 @@ class SessionHandler : public framing::AMQP_AllOperations::SessionHandler,
std::string name;
private:
+ void checkAttached();
void sendCommandPoint(const SessionPoint&);
};
}} // namespace qpid::amqp_0_10