You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/12/12 05:46:09 UTC
git commit: TS-2251: simplify LogBuffer reference counting
Updated Branches:
refs/heads/master a302c86ee -> 7244c89db
TS-2251: simplify LogBuffer reference counting
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7244c89d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7244c89d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7244c89d
Branch: refs/heads/master
Commit: 7244c89db2c0408c286f6f21fae94fceca24fd43
Parents: a302c86
Author: James Peach <jp...@apache.org>
Authored: Tue Dec 10 20:52:04 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Dec 11 20:45:09 2013 -0800
----------------------------------------------------------------------
CHANGES | 2 ++
proxy/logging/LogBuffer.h | 19 ++++++++-----------
2 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7244c89d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 22608c4..8a92590 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
Changes with Apache Traffic Server 4.2.0
+ *) [TS-2251] Simplify LogBuffer reference counting.
+
*) [TS-2190] Remove cache.log from the cachurl plugin.
*) [TS-2426] Add a new plugin, xdebug, for cache debugging using HTTP headers.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7244c89d/proxy/logging/LogBuffer.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.h b/proxy/logging/LogBuffer.h
index e12fa25..20ab601 100644
--- a/proxy/logging/LogBuffer.h
+++ b/proxy/logging/LogBuffer.h
@@ -188,20 +188,17 @@ public:
int write_to_len, long timestamp, long timestamp_us,
unsigned buffer_version, LogFieldList * alt_fieldlist = NULL,
char *alt_printf_str = NULL);
- static void destroy(LogBuffer *lb)
- {
- int result, old_ref, new_ref;
-
- do {
- old_ref = lb->m_references;
- new_ref = old_ref - 1;
- result = ink_atomic_cas(&lb->m_references, old_ref, new_ref);
- } while(!result);
- ink_release_assert(new_ref >= 0);
+ static void destroy(LogBuffer *lb) {
+ // ink_atomic_increment() returns the previous value, so when it was 1, we are
+ // the thread that decremented to zero and should delete ...
+ int refcnt = ink_atomic_increment(&lb->m_references, -1);
- if (new_ref == 0)
+ if (refcnt == 1) {
delete lb;
+ }
+
+ ink_release_assert(refcnt >= 0);
}
private: