summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-10-31 16:56:57 +0000
committerAlan Conway <aconway@apache.org>2007-10-31 16:56:57 +0000
commitff6f9f47dbbaaf84dde2a86dd8f854fcf3060378 (patch)
treee5474e9e0d23cec834b06c99cdaf9d4a98b1a0b5 /cpp/src/qpid/framing
parent3d05570dc824c704285bfef1ff810fbb1589f596 (diff)
downloadqpid-python-ff6f9f47dbbaaf84dde2a86dd8f854fcf3060378.tar.gz
Simplify SessionState, preparing for session thread safety fixes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@590751 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/SessionState.cpp21
-rw-r--r--cpp/src/qpid/framing/SessionState.h25
2 files changed, 6 insertions, 40 deletions
diff --git a/cpp/src/qpid/framing/SessionState.cpp b/cpp/src/qpid/framing/SessionState.cpp
index 8056f4a523..7e905bdf63 100644
--- a/cpp/src/qpid/framing/SessionState.cpp
+++ b/cpp/src/qpid/framing/SessionState.cpp
@@ -33,7 +33,6 @@ namespace qpid {
namespace framing {
SessionState::SessionState(uint32_t ack, const Uuid& uuid) :
- state(ATTACHED),
id(uuid),
lastReceived(-1),
lastSent(-1),
@@ -45,7 +44,6 @@ SessionState::SessionState(uint32_t ack, const Uuid& uuid) :
{}
SessionState::SessionState(const Uuid& uuid) :
- state(ATTACHED),
id(uuid),
lastReceived(-1),
lastSent(-1),
@@ -65,10 +63,6 @@ bool isSessionCommand(const AMQFrame& f) {
boost::optional<SequenceNumber> SessionState::received(const AMQFrame& f) {
if (isSessionCommand(f))
return boost::none;
- if (state==RESUMING)
- throw CommandInvalidException(
- QPID_MSG("Invalid frame: Resuming session, expected session-ack"));
- assert(state = ATTACHED);
++lastReceived;
QPID_LOG(trace, "Recv # "<< lastReceived << " " << id);
if (ackInterval && lastReceived == sendAckAt)
@@ -85,7 +79,6 @@ bool SessionState::sent(const AMQFrame& f) {
++lastSent;
QPID_LOG(trace, "Sent # "<< lastSent << " " << id);
return ackInterval &&
- (state!=RESUMING) &&
(lastSent == solicitAckAt) &&
sendingSolicit();
}
@@ -97,8 +90,6 @@ SessionState::Replay SessionState::replay() {
}
void SessionState::receivedAck(SequenceNumber acked) {
- if (state==RESUMING) state=ATTACHED;
- assert(state==ATTACHED);
if (lastSent < acked)
throw InvalidArgumentException("Invalid sequence number in ack");
size_t keep = lastSent - acked;
@@ -113,22 +104,10 @@ SequenceNumber SessionState::sendingAck() {
}
bool SessionState::sendingSolicit() {
- assert(state == ATTACHED);
if (ackSolicited)
return false;
solicitAckAt = lastSent + ackInterval;
return ackInterval != 0;
}
-SequenceNumber SessionState::resuming() {
- if (!resumable)
- throw InternalErrorException("Session is not resumable");
- state = RESUMING;
- return sendingAck();
-}
-
-void SessionState::suspend() {
- state = SUSPENDED;
-}
-
}} // namespace qpid::framing
diff --git a/cpp/src/qpid/framing/SessionState.h b/cpp/src/qpid/framing/SessionState.h
index 361c960db1..5034de4e94 100644
--- a/cpp/src/qpid/framing/SessionState.h
+++ b/cpp/src/qpid/framing/SessionState.h
@@ -35,7 +35,10 @@ namespace framing {
/**
* Session state common to client and broker.
- * Stores replay frames, implements session ack/resume protcools.
+ *
+ * Stores data needed to resume a session: replay frames, implements
+ * session ack/resume protcools. Stores handler chains for the session,
+ * handlers may themselves store state.
*
* A SessionState is always associated with an _open_ session (attached or
* suspended) it is destroyed when the session is closed.
@@ -46,13 +49,6 @@ class SessionState
public:
typedef std::vector<AMQFrame> Replay;
- /** States of a session. */
- enum State {
- SUSPENDED, ///< Suspended, detached from any channel.
- RESUMING, ///< Resuming: waiting for initial ack from peer.
- ATTACHED ///< Attached to channel and operating normally.
- };
-
/**
*Create a newly opened active session.
*@param ackInterval send/solicit an ack whenever N unacked frames
@@ -60,7 +56,8 @@ class SessionState
*
* N=0 disables voluntary send/solict ack.
*/
- SessionState(uint32_t ackInterval, const framing::Uuid& id=framing::Uuid(true));
+ SessionState(uint32_t ackInterval,
+ const framing::Uuid& id=framing::Uuid(true));
/**
* Create a non-resumable session. Does not store session frames,
@@ -69,7 +66,6 @@ class SessionState
SessionState(const framing::Uuid& id=framing::Uuid(true));
const framing::Uuid& getId() const { return id; }
- State getState() const { return state; }
/** Received incoming L3 frame.
* @return SequenceNumber if an ack should be sent, empty otherwise.
@@ -92,13 +88,6 @@ class SessionState
*/
Replay replay();
- /** Suspend the session. */
- void suspend();
-
- /** Start resume protocol for the session.
- *@returns sequence number to ack immediately. */
- SequenceNumber resuming();
-
/** About to send an unscheduled ack, e.g. to respond to a solicit-ack.
*
* Note: when received() returns a sequence number this function
@@ -115,9 +104,7 @@ class SessionState
bool sendingSolicit();
- State state;
framing::Uuid id;
-
Unacked unackedOut;
SequenceNumber lastReceived;
SequenceNumber lastSent;