You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/02/28 16:46:01 UTC
[1/6] git commit: TS-2585: add doc
Repository: trafficserver
Updated Branches:
refs/heads/master 062b4848d -> 48148ba23
TS-2585: add doc
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/eed4325f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/eed4325f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/eed4325f
Branch: refs/heads/master
Commit: eed4325f62460f2d5ecd5c0763eda88652c89bdf
Parents: c890e94
Author: Ethan Lai <yz...@yahoo.com>
Authored: Wed Feb 26 16:17:37 2014 +0000
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Feb 27 19:57:34 2014 -0700
----------------------------------------------------------------------
doc/reference/plugins/regex_remap.en.rst | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/eed4325f/doc/reference/plugins/regex_remap.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/regex_remap.en.rst b/doc/reference/plugins/regex_remap.en.rst
index 0f8c897..e9093ce 100644
--- a/doc/reference/plugins/regex_remap.en.rst
+++ b/doc/reference/plugins/regex_remap.en.rst
@@ -123,6 +123,7 @@ remap.config. The following options are available ::
@no_activity_timeout=<nnn> - No activity timeout (in ms)
@connect_timeout=<nnn> - Connect timeouts (in ms)
@dns_timeout=<nnn> - Connect timeouts (in ms)
+ @overridable-config=<value> - see :ref:`ts-overridable-config`
This can be useful to force a particular response for some URLs, e.g. ::
[2/6] git commit: TS-2585: add overridable configs support
Posted by zw...@apache.org.
TS-2585: add overridable configs support
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c890e945
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c890e945
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c890e945
Branch: refs/heads/master
Commit: c890e945c7555c992ae70177a6ceb2de1ec21be4
Parents: 062b484
Author: Ethan Lai <yz...@yahoo.com>
Authored: Wed Feb 26 16:11:41 2014 +0000
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Feb 27 19:57:34 2014 -0700
----------------------------------------------------------------------
plugins/regex_remap/regex_remap.cc | 79 ++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c890e945/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 111e292..3fcc254 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -118,7 +118,8 @@ class RemapRegex
public:
RemapRegex(const std::string& reg, const std::string& sub, const std::string& opt) :
_num_subs(-1), _rex(NULL), _extra(NULL), _order(-1), _simple(false), _lowercase_substitutions(false),
- _active_timeout(-1), _no_activity_timeout(-1), _connect_timeout(-1), _dns_timeout(-1)
+ _active_timeout(-1), _no_activity_timeout(-1), _connect_timeout(-1), _dns_timeout(-1),
+ _first_item(NULL), _last_item(NULL)
{
TSDebug(PLUGIN_NAME, "Calling constructor");
@@ -180,7 +181,41 @@ class RemapRegex
_lowercase_substitutions = atoi(opt_val.c_str());
TSDebug(PLUGIN_NAME, "lowercasing %d", _lowercase_substitutions);
} else {
- TSError("Unknown options: %s", opt.c_str());
+ TSOverridableConfigKey name;
+ TSRecordDataType type;
+ std::string opt_name = opt.substr(start, pos1-start-1);
+ if (TS_SUCCESS == TSHttpTxnConfigFind(opt_name.c_str(), opt_name.length(), &name, &type)) {
+ Item *cur = (Item *) TSmalloc(sizeof(Item));
+ switch (type) {
+ case TS_RECORDDATATYPE_INT:
+ cur->data.rec_int = strtoll(opt_val.c_str(), NULL, 10);
+ break;
+ case TS_RECORDDATATYPE_STRING:
+ cur->data.rec_string = TSstrdup(opt_val.c_str());
+ cur->data_len = opt_val.size();
+ break;
+ default:
+ TSfree(cur);
+ cur = NULL;
+ TSError("%s: configuration variable '%s' is of an unsupported type", PLUGIN_NAME, opt_name.c_str());
+ break;
+ }
+ if (cur) {
+ TSDebug(PLUGIN_NAME, "%s = %s", opt_name.c_str(), opt_val.c_str());
+ cur->name = name;
+ cur->type = type;
+ cur->next = NULL;
+ if (NULL == _first_item) {
+ _first_item = cur;
+ _last_item = cur;
+ } else {
+ _last_item->next = cur;
+ _last_item = cur;
+ }
+ }
+ } else {
+ TSError("Unknown options: %s", opt.c_str());
+ }
}
start = opt.find_first_of("@", pos2);
}
@@ -490,6 +525,16 @@ class RemapRegex
inline int dns_timeout_option() const { return _dns_timeout; };
inline bool lowercase_substitutions_option() const { return _lowercase_substitutions; };
+ struct Item {
+ TSOverridableConfigKey name;
+ TSRecordDataType type;
+ TSRecordData data;
+ int data_len; // Used when data is a string
+ Item* next;
+ };
+
+ inline Item* get_override_items() const { return _first_item; };
+
private:
char* _rex_string;
char* _subst;
@@ -510,6 +555,9 @@ class RemapRegex
int _no_activity_timeout;
int _connect_timeout;
int _dns_timeout;
+
+ Item* _first_item;
+ Item* _last_item;
};
struct RemapInstance
@@ -762,6 +810,15 @@ TSRemapDeleteInstance(void* ih)
re = ri->first;
while (re) {
+ RemapRegex::Item *item = re->get_override_items();
+ while (item) {
+ RemapRegex::Item *tmp = item;
+ if (TS_RECORDDATATYPE_STRING == item->type) {
+ TSfree(item->data.rec_string);
+ }
+ item = item->next;
+ TSfree(tmp);
+ }
tmp = re;
re = re->next();
delete tmp;
@@ -862,6 +919,24 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
TSDebug(PLUGIN_NAME, "Setting lowercasing substitutions on");
lowercase_substitutions = true;
}
+ if (re->get_override_items() != NULL) {
+ RemapRegex::Item *item = re->get_override_items();
+ while (item) {
+ switch (item->type) {
+ case TS_RECORDDATATYPE_INT:
+ TSHttpTxnConfigIntSet(txnp, item->name, item->data.rec_int);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to %" PRId64"", item->name, item->data.rec_int);
+ break;
+ case TS_RECORDDATATYPE_STRING:
+ TSHttpTxnConfigStringSet(txnp, item->name, item->data.rec_string, item->data_len);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to %s", item->name, item->data.rec_string);
+ break;
+ default:
+ break; // Error ?
+ }
+ item = item->next;
+ }
+ }
// Update profiling if requested
if (ri->profile) {
[5/6] git commit: Added TS-2585 to CHANGES.
Posted by zw...@apache.org.
Added TS-2585 to CHANGES.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f4dae027
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f4dae027
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f4dae027
Branch: refs/heads/master
Commit: f4dae027cf23340fb6237b6824362a433e2d36af
Parents: 2438590
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Feb 28 08:41:35 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Feb 28 08:41:35 2014 -0700
----------------------------------------------------------------------
CHANGES | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f4dae027/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 08da8bc..7131446 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.0.0
+ *) [TS-2585] Add overridable configs support to regex_remap plugin.
+ Author: Ethan Lai <yz...@yahoo.com>
+
*) [TS-2569] Set the default SSL options correctly.
Author: Ron Barber <rb...@yahoo-inc.com>
@@ -1324,7 +1327,7 @@ Changes with Apache Traffic Server 3.3.1
*) [TS-1500] let ssl_multicert.config specify sslcert per port
*) [TS-1621] Adopt ConfigUpdateHandler pattern.
- Author: Ethan Lai <yz...@yahoo.com>
+ Author: Ethan Lai <yz...@yahoo.com>
*) [TS-1619] simplify ConfigurationProcessor reconfiguration pattern.
[3/6] git commit: TS-2585 Minor cleanup.
Posted by zw...@apache.org.
TS-2585 Minor cleanup.
This closes #50
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e2d31b27
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e2d31b27
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e2d31b27
Branch: refs/heads/master
Commit: e2d31b2789bd91260af5f46b132ca009dbdac681
Parents: eed4325
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Feb 27 21:49:59 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Feb 28 08:20:48 2014 -0700
----------------------------------------------------------------------
plugins/regex_remap/regex_remap.cc | 133 +++++++++++++++++---------------
1 file changed, 70 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e2d31b27/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 3fcc254..bafb492 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -119,7 +119,7 @@ class RemapRegex
RemapRegex(const std::string& reg, const std::string& sub, const std::string& opt) :
_num_subs(-1), _rex(NULL), _extra(NULL), _order(-1), _simple(false), _lowercase_substitutions(false),
_active_timeout(-1), _no_activity_timeout(-1), _connect_timeout(-1), _dns_timeout(-1),
- _first_item(NULL), _last_item(NULL)
+ _first_override(NULL), _last_override(NULL)
{
TSDebug(PLUGIN_NAME, "Calling constructor");
@@ -179,13 +179,17 @@ class RemapRegex
_dns_timeout = atoi(opt_val.c_str());
} else if (opt.compare(start, 23, "lowercase_substitutions") == 0) {
_lowercase_substitutions = atoi(opt_val.c_str());
- TSDebug(PLUGIN_NAME, "lowercasing %d", _lowercase_substitutions);
+ TSDebug(PLUGIN_NAME, "Lowercasing %d", _lowercase_substitutions);
} else {
TSOverridableConfigKey name;
TSRecordDataType type;
std::string opt_name = opt.substr(start, pos1-start-1);
+
if (TS_SUCCESS == TSHttpTxnConfigFind(opt_name.c_str(), opt_name.length(), &name, &type)) {
- Item *cur = (Item *) TSmalloc(sizeof(Item));
+ Override* cur = new Override;
+
+ cur.set_value(type, opt_val);
+
switch (type) {
case TS_RECORDDATATYPE_INT:
cur->data.rec_int = strtoll(opt_val.c_str(), NULL, 10);
@@ -195,22 +199,22 @@ class RemapRegex
cur->data_len = opt_val.size();
break;
default:
- TSfree(cur);
+ delete cur;
cur = NULL;
TSError("%s: configuration variable '%s' is of an unsupported type", PLUGIN_NAME, opt_name.c_str());
break;
}
if (cur) {
- TSDebug(PLUGIN_NAME, "%s = %s", opt_name.c_str(), opt_val.c_str());
+ TSDebug(PLUGIN_NAME, "Overridable config %s=%s", opt_name.c_str(), opt_val.c_str());
cur->name = name;
cur->type = type;
cur->next = NULL;
- if (NULL == _first_item) {
- _first_item = cur;
- _last_item = cur;
+ if (NULL == _first_override) {
+ _first_override = cur;
+ _last_override = cur;
} else {
- _last_item->next = cur;
- _last_item = cur;
+ _last_override->next = cur;
+ _last_override = cur;
}
}
} else {
@@ -219,7 +223,7 @@ class RemapRegex
}
start = opt.find_first_of("@", pos2);
}
- };
+ }
~RemapRegex()
{
@@ -233,13 +237,13 @@ class RemapRegex
pcre_free(_rex);
if (_extra)
pcre_free(_extra);
- };
+ }
// For profiling information
inline void
print(int ix, int max, const char* now)
{
- fprintf(stderr, "[%s]:\tRegex %d ( %s ): %.2f%%\n", now, ix, _rex_string, 100.0 * _hits / max);
+ fprintf(stderr, "[%s]: Regex %d ( %s ): %.2f%%\n", now, ix, _rex_string, 100.0 * _hits / max);
}
inline void
@@ -336,7 +340,7 @@ class RemapRegex
}
}
return 0;
- };
+ }
// Perform the regular expression matching against a string.
int
@@ -350,7 +354,7 @@ class RemapRegex
0, // default options
ovector, // output vector for substring information
OVECCOUNT); // number of elements in the output vector
- };
+ }
// Get the lengths of the matching string(s), taking into account variable substitutions.
// We also calculate a total length for the new string, which is the max length the
@@ -407,7 +411,7 @@ class RemapRegex
}
return len;
- };
+ }
// Perform substitution on the $0 - $9 variables in the "src" string. $0 is the entire
// regex that was matches, while $1 - $9 are the corresponding groups. Return the final
@@ -501,39 +505,40 @@ class RemapRegex
}
return 0; // Shouldn't happen.
- };
+ }
// setter / getters for members the linked list.
- inline void set_next(RemapRegex* next) { _next = next; };
- inline RemapRegex* next() const { return _next; };
+ inline void set_next(RemapRegex* next) { _next = next; }
+ inline RemapRegex* next() const { return _next; }
// setter / getters for order number within the linked list
- inline void set_order(int order) { _order = order; };
- inline int order() { return _order; };
+ inline void set_order(int order) { _order = order; }
+ inline int order() { return _order; }
// Various getters
- inline const char* regex() const { return _rex_string; };
- inline const char* substitution() const { return _subst; };
+ inline const char* regex() const { return _rex_string; }
+ inline const char* substitution() const { return _subst; }
inline int substitutions_used() const { return _num_subs; }
inline bool is_simple() const { return _simple; }
- inline TSHttpStatus status_option() const { return _status; };
- inline int active_timeout_option() const { return _active_timeout; };
- inline int no_activity_timeout_option() const { return _no_activity_timeout; };
- inline int connect_timeout_option() const { return _connect_timeout; };
- inline int dns_timeout_option() const { return _dns_timeout; };
- inline bool lowercase_substitutions_option() const { return _lowercase_substitutions; };
+ inline TSHttpStatus status_option() const { return _status; }
+ inline int active_timeout_option() const { return _active_timeout; }
+ inline int no_activity_timeout_option() const { return _no_activity_timeout; }
+ inline int connect_timeout_option() const { return _connect_timeout; }
+ inline int dns_timeout_option() const { return _dns_timeout; }
+ inline bool lowercase_substitutions_option() const { return _lowercase_substitutions; }
- struct Item {
+ // Hold an overridable configurations
+ struct Override {
TSOverridableConfigKey name;
TSRecordDataType type;
TSRecordData data;
int data_len; // Used when data is a string
- Item* next;
+ Override* next;
};
- inline Item* get_override_items() const { return _first_item; };
+ Override* get_overrides() const { return _first_override; }
private:
char* _rex_string;
@@ -556,8 +561,8 @@ class RemapRegex
int _connect_timeout;
int _dns_timeout;
- Item* _first_item;
- Item* _last_item;
+ Override* _first_override;
+ Override* _last_override;
};
struct RemapInstance
@@ -566,7 +571,7 @@ struct RemapInstance
first(NULL), last(NULL), profile(false), method(false), query_string(true),
matrix_params(false), hits(0), misses(0),
filename("unknown")
- { };
+ { }
RemapRegex* first;
RemapRegex* last;
@@ -620,7 +625,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
}
setup_memory_allocation();
- TSDebug(PLUGIN_NAME, "plugin is successfully initialized");
+ TSDebug(PLUGIN_NAME, "Plugin is successfully initialized");
return TS_SUCCESS;
}
@@ -693,7 +698,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
TSError("%s: unable to open %s", PLUGIN_NAME, (ri->filename).c_str());
return TS_ERROR;
}
- TSDebug(PLUGIN_NAME, "loading regular expression maps from %s", (ri->filename).c_str());
+ TSDebug(PLUGIN_NAME, "Loading regular expressions from %s", (ri->filename).c_str());
while (!f.eof()) {
std::string line, regex, subst, options;
@@ -752,7 +757,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
PLUGIN_NAME, (ri->filename).c_str(), lineno, erroffset, error);
delete(cur);
} else {
- TSDebug(PLUGIN_NAME, "added regex=%s with substitution=%s and options `%s'",
+ TSDebug(PLUGIN_NAME, "Added regex=%s with subs=%s and options `%s'",
regex.c_str(), subst.c_str(), options.c_str());
cur->set_order(++count);
if (ri->first == NULL)
@@ -793,8 +798,8 @@ TSRemapDeleteInstance(void* ih)
}
fprintf(stderr, "[%s]: Profiling information for regex_remap file `%s':\n", now, (ri->filename).c_str());
- fprintf(stderr, "[%s]:\tTotal hits (matches): %d\n", now, ri->hits);
- fprintf(stderr, "[%s]:\tTotal missed (no regex matches): %d\n", now, ri->misses);
+ fprintf(stderr, "[%s]: Total hits (matches): %d\n", now, ri->hits);
+ fprintf(stderr, "[%s]: Total missed (no regex matches): %d\n", now, ri->misses);
if (ri->hits > 0) { // Avoid divide by zeros...
int ix = 1;
@@ -810,14 +815,16 @@ TSRemapDeleteInstance(void* ih)
re = ri->first;
while (re) {
- RemapRegex::Item *item = re->get_override_items();
- while (item) {
- RemapRegex::Item *tmp = item;
- if (TS_RECORDDATATYPE_STRING == item->type) {
- TSfree(item->data.rec_string);
+ RemapRegex::Override *override = re->get_overrides();
+
+ while (override) {
+ RemapRegex::Override* tmp = override;
+
+ if (TS_RECORDDATATYPE_STRING == override->type) {
+ TSfree(override->data.rec_string);
}
- item = item->next;
- TSfree(tmp);
+ override = override->next;
+ delete tmp;
}
tmp = re;
re = re->next();
@@ -919,23 +926,23 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
TSDebug(PLUGIN_NAME, "Setting lowercasing substitutions on");
lowercase_substitutions = true;
}
- if (re->get_override_items() != NULL) {
- RemapRegex::Item *item = re->get_override_items();
- while (item) {
- switch (item->type) {
- case TS_RECORDDATATYPE_INT:
- TSHttpTxnConfigIntSet(txnp, item->name, item->data.rec_int);
- TSDebug(PLUGIN_NAME, "Setting config id %d to %" PRId64"", item->name, item->data.rec_int);
- break;
- case TS_RECORDDATATYPE_STRING:
- TSHttpTxnConfigStringSet(txnp, item->name, item->data.rec_string, item->data_len);
- TSDebug(PLUGIN_NAME, "Setting config id %d to %s", item->name, item->data.rec_string);
- break;
- default:
- break; // Error ?
- }
- item = item->next;
+
+ RemapRegex::Override *override = re->get_overrides();
+
+ while (override) {
+ switch (override->type) {
+ case TS_RECORDDATATYPE_INT:
+ TSHttpTxnConfigIntSet(txnp, override->name, override->data.rec_int);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%" PRId64 "'", override->name, override->data.rec_int);
+ break;
+ case TS_RECORDDATATYPE_STRING:
+ TSHttpTxnConfigStringSet(txnp, override->name, override->data.rec_string, override->data_len);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%s'", override->name, override->data.rec_string);
+ break;
+ default:
+ break; // Error ?
}
+ override = override->next;
}
// Update profiling if requested
[6/6] git commit: TS-2585 Minor cleanup of variable name
Posted by zw...@apache.org.
TS-2585 Minor cleanup of variable name
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/48148ba2
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/48148ba2
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/48148ba2
Branch: refs/heads/master
Commit: 48148ba23c570a151365c1a2b3c1dc4d6316bba2
Parents: f4dae02
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Feb 28 08:45:52 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Feb 28 08:45:52 2014 -0700
----------------------------------------------------------------------
plugins/regex_remap/regex_remap.cc | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48148ba2/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 4b0e668..519ba25 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -182,11 +182,11 @@ class RemapRegex
_lowercase_substitutions = atoi(opt_val.c_str());
TSDebug(PLUGIN_NAME, "Lowercasing %d", _lowercase_substitutions);
} else {
- TSOverridableConfigKey name;
+ TSOverridableConfigKey key;
TSRecordDataType type;
std::string opt_name = opt.substr(start, pos1-start-1);
- if (TS_SUCCESS == TSHttpTxnConfigFind(opt_name.c_str(), opt_name.length(), &name, &type)) {
+ if (TS_SUCCESS == TSHttpTxnConfigFind(opt_name.c_str(), opt_name.length(), &key, &type)) {
Override* cur = new Override;
switch (type) {
@@ -208,7 +208,7 @@ class RemapRegex
}
if (cur) {
TSDebug(PLUGIN_NAME, "Overridable config %s=%s", opt_name.c_str(), opt_val.c_str());
- cur->name = name;
+ cur->key = key;
cur->type = type;
cur->next = NULL;
if (NULL == last_override) {
@@ -532,7 +532,7 @@ class RemapRegex
// Hold an overridable configurations
struct Override {
- TSOverridableConfigKey name;
+ TSOverridableConfigKey key;
TSRecordDataType type;
TSRecordData data;
int data_len; // Used when data is a string
@@ -932,16 +932,16 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
while (override) {
switch (override->type) {
case TS_RECORDDATATYPE_INT:
- TSHttpTxnConfigIntSet(txnp, override->name, override->data.rec_int);
- TSDebug(PLUGIN_NAME, "Setting config id %d to `%" PRId64 "'", override->name, override->data.rec_int);
+ TSHttpTxnConfigIntSet(txnp, override->key, override->data.rec_int);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%" PRId64 "'", override->key, override->data.rec_int);
break;
case TS_RECORDDATATYPE_FLOAT:
- TSHttpTxnConfigFloatSet(txnp, override->name, override->data.rec_float);
- TSDebug(PLUGIN_NAME, "Setting config id %d to `%f'", override->name, override->data.rec_float);
+ TSHttpTxnConfigFloatSet(txnp, override->key, override->data.rec_float);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%f'", override->key, override->data.rec_float);
break;
case TS_RECORDDATATYPE_STRING:
- TSHttpTxnConfigStringSet(txnp, override->name, override->data.rec_string, override->data_len);
- TSDebug(PLUGIN_NAME, "Setting config id %d to `%s'", override->name, override->data.rec_string);
+ TSHttpTxnConfigStringSet(txnp, override->key, override->data.rec_string, override->data_len);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%s'", override->key, override->data.rec_string);
break;
default:
break; // Error ?
[4/6] git commit: TS-2585 Add support for float type as well
Posted by zw...@apache.org.
TS-2585 Add support for float type as well
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2438590f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2438590f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2438590f
Branch: refs/heads/master
Commit: 2438590f47ef310b6c27389e16472db2c7de4906
Parents: e2d31b2
Author: Leif Hedstrom <zw...@apache.org>
Authored: Fri Feb 28 08:36:08 2014 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Fri Feb 28 08:36:08 2014 -0700
----------------------------------------------------------------------
plugins/regex_remap/regex_remap.cc | 44 ++++++++++++++++++---------------
1 file changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2438590f/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index bafb492..4b0e668 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -119,7 +119,7 @@ class RemapRegex
RemapRegex(const std::string& reg, const std::string& sub, const std::string& opt) :
_num_subs(-1), _rex(NULL), _extra(NULL), _order(-1), _simple(false), _lowercase_substitutions(false),
_active_timeout(-1), _no_activity_timeout(-1), _connect_timeout(-1), _dns_timeout(-1),
- _first_override(NULL), _last_override(NULL)
+ _first_override(NULL)
{
TSDebug(PLUGIN_NAME, "Calling constructor");
@@ -151,6 +151,7 @@ class RemapRegex
// Parse options
std::string::size_type start = opt.find_first_of("@");
std::string::size_type pos1, pos2;
+ Override* last_override = NULL;
while (start != std::string::npos) {
std::string opt_val;
@@ -188,34 +189,34 @@ class RemapRegex
if (TS_SUCCESS == TSHttpTxnConfigFind(opt_name.c_str(), opt_name.length(), &name, &type)) {
Override* cur = new Override;
- cur.set_value(type, opt_val);
-
switch (type) {
- case TS_RECORDDATATYPE_INT:
- cur->data.rec_int = strtoll(opt_val.c_str(), NULL, 10);
- break;
- case TS_RECORDDATATYPE_STRING:
- cur->data.rec_string = TSstrdup(opt_val.c_str());
- cur->data_len = opt_val.size();
- break;
- default:
- delete cur;
- cur = NULL;
- TSError("%s: configuration variable '%s' is of an unsupported type", PLUGIN_NAME, opt_name.c_str());
- break;
+ case TS_RECORDDATATYPE_INT:
+ cur->data.rec_int = strtoll(opt_val.c_str(), NULL, 10);
+ break;
+ case TS_RECORDDATATYPE_FLOAT:
+ cur->data.rec_float = strtof(opt_val.c_str(), NULL);
+ break;
+ case TS_RECORDDATATYPE_STRING:
+ cur->data.rec_string = TSstrdup(opt_val.c_str());
+ cur->data_len = opt_val.size();
+ break;
+ default:
+ delete cur;
+ cur = NULL;
+ TSError("%s: configuration variable '%s' is of an unsupported type", PLUGIN_NAME, opt_name.c_str());
+ break;
}
if (cur) {
TSDebug(PLUGIN_NAME, "Overridable config %s=%s", opt_name.c_str(), opt_val.c_str());
cur->name = name;
cur->type = type;
cur->next = NULL;
- if (NULL == _first_override) {
+ if (NULL == last_override) {
_first_override = cur;
- _last_override = cur;
} else {
- _last_override->next = cur;
- _last_override = cur;
+ last_override->next = cur;
}
+ last_override = cur;
}
} else {
TSError("Unknown options: %s", opt.c_str());
@@ -562,7 +563,6 @@ class RemapRegex
int _dns_timeout;
Override* _first_override;
- Override* _last_override;
};
struct RemapInstance
@@ -935,6 +935,10 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
TSHttpTxnConfigIntSet(txnp, override->name, override->data.rec_int);
TSDebug(PLUGIN_NAME, "Setting config id %d to `%" PRId64 "'", override->name, override->data.rec_int);
break;
+ case TS_RECORDDATATYPE_FLOAT:
+ TSHttpTxnConfigFloatSet(txnp, override->name, override->data.rec_float);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to `%f'", override->name, override->data.rec_float);
+ break;
case TS_RECORDDATATYPE_STRING:
TSHttpTxnConfigStringSet(txnp, override->name, override->data.rec_string, override->data_len);
TSDebug(PLUGIN_NAME, "Setting config id %d to `%s'", override->name, override->data.rec_string);