Fixed IpMap::unmark
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/855bbd6e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/855bbd6e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/855bbd6e Branch: refs/heads/master Commit: 855bbd6e81091bba1568dcf8014f17f78c466798 Parents: c12f061 Author: Alan M. Carroll <[email protected]> Authored: Sun Mar 18 23:44:36 2012 -0500 Committer: Alan M. Carroll <[email protected]> Committed: Sun Mar 18 23:44:36 2012 -0500 ---------------------------------------------------------------------- lib/ts/IpMap.cc | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/855bbd6e/lib/ts/IpMap.cc ---------------------------------------------------------------------- diff --git a/lib/ts/IpMap.cc b/lib/ts/IpMap.cc index 34009f7..14ce6ab 100644 --- a/lib/ts/IpMap.cc +++ b/lib/ts/IpMap.cc @@ -837,18 +837,15 @@ IpMapBase<N>::unmark(ArgType min, ArgType max) { // Need to handle special case where first span starts to the left. if (n && n->_min < min) { if (n->_max >= min) { // some overlap - Metric min_1 = N::deref(min); - N::dec(min_1); if (n->_max > max) { // request span is covered by existing span - split existing span. - Metric max_plus = N::deref(max); - N::inc(max_plus); - x = new N(max_plus, n->_max, n->_data); - n->setMax(min_1); + x = new N(max, N::argue(n->_max), n->_data); + x->incrementMin(); + n->setMaxMinusOne(N::deref(min)); this->insertAfter(n, x); return *this; // done. } else { - n->setMax(min_1); // just clip overloap. + n->setMaxMinusOne(N::deref(min)); // just clip overlap. } } // else disjoint so just skip it. n = next(n); @@ -861,9 +858,7 @@ IpMapBase<N>::unmark(ArgType min, ArgType max) { this->remove(x); } else { if (x->_min <= max) { // clip overlap - Metric max_plus = N::deref(max); - N::inc(max_plus); - x->setMin(max_plus); + x->setMinPlusOne(N::deref(max)); } break; } @@ -1043,6 +1038,13 @@ protected: this->setMax(_max-1); return *this; } + /** Increment the minimum value in place. + @return This object. + */ + self& incrementMin() { + this->setMin(_min+1); + return *this; + } /// Increment a metric. static void inc( @@ -1185,6 +1187,10 @@ protected: @return This object. */ self& decrementMax() { dec(_max); return *this; } + /** Increment the mininimum value in place. + @return This object. + */ + self& incrementMin() { inc(_min); return *this; } /// Increment a metric. static void inc( @@ -1218,6 +1224,13 @@ protected: return *addr; } + /// @return The argument type for the @a metric. + static ArgType argue( + Metric const& metric + ) { + return &metric; + } + }; // We declare this after the helper operators and inside this namespace
