diff options
| author | Gordon Sim <gsim@apache.org> | 2015-01-23 20:25:45 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2015-01-23 20:25:45 +0000 |
| commit | e08c11b991309252a19a572024961550e5adaf11 (patch) | |
| tree | 30d0057b5854cf750b169241208dd3d70b65eac4 /qpid/cpp/src | |
| parent | 267ac19aea62d4d9861e377c2201553d80dd1fde (diff) | |
| download | qpid-python-e08c11b991309252a19a572024961550e5adaf11.tar.gz | |
QPID-6310: handle maximal range
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1654365 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/framing/SequenceSet.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/framing/SequenceSet.cpp b/qpid/cpp/src/qpid/framing/SequenceSet.cpp index 845bf8bfae..6510842c58 100644 --- a/qpid/cpp/src/qpid/framing/SequenceSet.cpp +++ b/qpid/cpp/src/qpid/framing/SequenceSet.cpp @@ -33,7 +33,18 @@ namespace framing { namespace { //each range contains 2 numbers, 4 bytes each -uint16_t RANGE_SIZE = 2 * 4; +uint16_t RANGE_SIZE = 2 * 4; +int32_t MAX_RANGE = 2147483647;//2^31-1 + +int32_t gap(const SequenceNumber& a, const SequenceNumber& b) +{ + return a < b ? b - a : a - b; +} + +bool is_max_range(const SequenceNumber& a, const SequenceNumber& b) +{ + return gap(a, b) == MAX_RANGE; +} } void SequenceSet::encode(Buffer& buffer) const @@ -58,7 +69,17 @@ void SequenceSet::decode(Buffer& buffer) SequenceNumber b(buffer.getLong()); if (b < a) throw IllegalArgumentException(QPID_MSG("Invalid range in sequence set: " << a << " -> " << b)); - add(a, b); + if (is_max_range(a, b)) { + //RangeSet holds 'half-closed' ranges, where the end is + //one past the 'highest' value in the range. So if the + //range is already the maximum expressable with a 32bit + //sequence number, we can't represent it as a + //'half-closed' range, so we represent it as two ranges. + add(a, b-1); + add(b); + } else { + add(a, b); + } } } |
