You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ni...@apache.org on 2015/07/08 12:13:53 UTC
trafficserver git commit: stream_editor: reference-count rules,
and hope it satisfies coverity scan.
Repository: trafficserver
Updated Branches:
refs/heads/master 17ca6e33c -> 065bf15a5
stream_editor: reference-count rules, and hope it satisfies coverity scan.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/065bf15a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/065bf15a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/065bf15a
Branch: refs/heads/master
Commit: 065bf15a5f86dddd6b06545d958e275be5216ac8
Parents: 17ca6e3
Author: Nick Kew <nk...@qualys.com>
Authored: Wed Jul 8 11:11:52 2015 +0100
Committer: Nick Kew <nk...@qualys.com>
Committed: Wed Jul 8 11:11:52 2015 +0100
----------------------------------------------------------------------
.../experimental/stream_editor/stream_editor.cc | 27 ++++++++++----------
1 file changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/065bf15a/plugins/experimental/stream_editor/stream_editor.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/stream_editor/stream_editor.cc b/plugins/experimental/stream_editor/stream_editor.cc
index 743cf15..072a225 100644
--- a/plugins/experimental/stream_editor/stream_editor.cc
+++ b/plugins/experimental/stream_editor/stream_editor.cc
@@ -383,9 +383,10 @@ private:
unsigned int priority;
match_t *from;
char *to;
+ int *refcount;
public:
- rule_t(const char *line) : scope(NULL), priority(5), from(NULL), to(NULL)
+ rule_t(const char *line) : scope(NULL), priority(5), from(NULL), to(NULL), refcount(NULL)
{
const char *scope_spec = strcasestr(line, "scope:");
const char *from_spec = strcasestr(line, "from:");
@@ -494,24 +495,24 @@ public:
}
}
to = TSstrndup(to_spec, len);
+
+ refcount = new int(1);
}
- rule_t(const rule_t &r) : scope(r.scope), priority(r.priority), from(r.from), to(r.to) {}
- /* FIXME - since rules get copied per-request, we can't delete these.
- But we can leave these to leak 'cos they're only ever created
- as a one-off at startup. Would be cleaner to refcount or to
- use subclasses with and without destructor for original vs copy.
- ~rule_t() {
- if (scope) delete scope;
- if (from) delete from;
- if (to) TSfree(to);
- }
- */
+ rule_t(const rule_t &r) : scope(r.scope), priority(r.priority), from(r.from), to(r.to), refcount(r.refcount) { ++*refcount; }
+ ~rule_t() {
+ if (!refcount || !--*refcount) {
+ if (scope) delete scope;
+ if (from) delete from;
+ if (to) TSfree(to);
+ }
+ if (refcount) delete refcount;
+ }
bool
in_scope(TSHttpTxn tx) const
{
- /* if no scope is specified then everything is in-scope */
+ /* if no scope was specified then everything is in-scope */
return scope ? scope->in_scope(tx) : true;
}