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 2010/09/16 22:13:20 UTC
svn commit: r997909 - in /trafficserver/traffic/trunk: ./ proxy/
proxy/http2/ proxy/http2/remap/
Author: zwoop
Date: Thu Sep 16 20:13:19 2010
New Revision: 997909
URL: http://svn.apache.org/viewvc?rev=997909&view=rev
Log:
TS-224 Cleanup / fixed for remap and remap chaining.
Tested: Fedora Core 13, Ubuntu 10.04, FreeBSD, MacOSX.
Added:
trafficserver/traffic/trunk/proxy/http2/remap/Makefile.am
Modified:
trafficserver/traffic/trunk/configure.ac
trafficserver/traffic/trunk/proxy/Makefile.am
trafficserver/traffic/trunk/proxy/http2/Makefile.am
trafficserver/traffic/trunk/proxy/http2/remap/AclFiltering.h
trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.cc
trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.h
trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.cc
trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.h
trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.cc
trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.h
trafficserver/traffic/trunk/proxy/http2/remap/StringHash.cc
trafficserver/traffic/trunk/proxy/http2/remap/StringHash.h
trafficserver/traffic/trunk/proxy/http2/remap/Trie.h
trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.cc
trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.h
trafficserver/traffic/trunk/proxy/http2/remap/UrlMappingPathIndex.h
trafficserver/traffic/trunk/proxy/http2/remap/UrlRewrite.cc
Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Thu Sep 16 20:13:19 2010
@@ -1168,6 +1168,7 @@ AC_CONFIG_FILES([proxy/config/Makefile])
AC_CONFIG_FILES([proxy/congest/Makefile])
AC_CONFIG_FILES([proxy/hdrs/Makefile])
AC_CONFIG_FILES([proxy/http2/Makefile])
+AC_CONFIG_FILES([proxy/http2/remap/Makefile])
AC_CONFIG_FILES([proxy/logging/Makefile])
AC_CONFIG_FILES([proxy/Makefile])
AC_CONFIG_FILES([proxy/mgmt2/api2/Makefile])
Modified: trafficserver/traffic/trunk/proxy/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Makefile.am?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/Makefile.am Thu Sep 16 20:13:19 2010
@@ -152,6 +152,7 @@ traffic_server_SOURCES = \
traffic_server_LDFLAGS = @EXTRA_CXX_LDFLAGS@
traffic_server_LDADD = \
http2/libhttp.a \
+ http2/remap/libhttp_remap.a \
congest/libCongestionControl.a \
logging/liblogging.a \
stats/libstats.a \
Modified: trafficserver/traffic/trunk/proxy/http2/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/Makefile.am?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/http2/Makefile.am Thu Sep 16 20:13:19 2010
@@ -16,6 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+SUBDIRS = remap
+
AM_CPPFLAGS = \
$(iocore_include_dirs) \
-I$(top_srcdir)/proxy \
Modified: trafficserver/traffic/trunk/proxy/http2/remap/AclFiltering.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/AclFiltering.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/AclFiltering.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/AclFiltering.h Thu Sep 16 20:13:19 2010
@@ -39,6 +39,7 @@ typedef struct src_ip_info_t
unsigned long start; // IPv4 address value stores start of a range (host byte order)
unsigned long end; // IPv4 address value stores end of a range (host byte order)
bool invert; // Should we "invert" the meaning of this IP range ("not in range")
+
void reset(void)
{
start = (end = 0);
@@ -54,17 +55,20 @@ class acl_filter_rule
{
private:
void reset(void);
+
public:
- acl_filter_rule * next;
+ acl_filter_rule * next;
int filter_name_size; // size of optional filter name
char *filter_name; // optional filter name
unsigned int allow_flag:1, // action allow deny
method_valid:1, // method valid for verification
src_ip_valid:1, // src_ip range valid
active_queue_flag:1; // filter is in active state (used by .useflt directive)
+
// we need arguments as string array for directive processing
int argc; // argument counter (only for filter defs)
char *argv[ACL_FILTER_MAX_ARGV]; // argument strings (only for filter defs)
+
// method
int method_cnt; // how many valid methods we have
int method_array[ACL_FILTER_MAX_METHODS]; // any HTTP method (actually only WKSIDX from HTTP.cc)
Added: trafficserver/traffic/trunk/proxy/http2/remap/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/Makefile.am?rev=997909&view=auto
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/Makefile.am (added)
+++ trafficserver/traffic/trunk/proxy/http2/remap/Makefile.am Thu Sep 16 20:13:19 2010
@@ -0,0 +1,47 @@
+# Makefile.am for Http
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+AM_CPPFLAGS = \
+ $(iocore_include_dirs) \
+ -I$(top_srcdir)/proxy \
+ -I$(top_srcdir)/proxy/mgmt2 \
+ -I$(top_srcdir)/proxy/mgmt2/preparse \
+ -I$(top_srcdir)/proxy/mgmt2/utils \
+ -I$(top_srcdir)/proxy/hdrs \
+ -I$(top_srcdir)/proxy/http2
+
+noinst_LIBRARIES = libhttp_remap.a
+
+libhttp_remap_a_SOURCES = \
+ AclFiltering.cc \
+ AclFiltering.h \
+ RemapPluginInfo.cc \
+ RemapPluginInfo.h \
+ RemapPlugins.cc \
+ RemapPlugins.h \
+ RemapProcessor.cc \
+ RemapProcessor.h \
+ StringHash.cc \
+ StringHash.h \
+ UrlMapping.cc \
+ UrlMapping.h \
+ UrlRewrite.cc \
+ UrlRewrite.h \
+ Trie.h \
+ UrlMappingPathIndex.h \
+ UrlMappingPathIndex.cc
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.cc Thu Sep 16 20:13:19 2010
@@ -23,35 +23,21 @@
#include "RemapPluginInfo.h"
-pthread_mutex_t
- remap_plugin_info::global_list_mutex;
-remap_plugin_info_init
- instance_of_remap_plugin_info_init;
-
-/**
- *
-**/
+// Globals
+pthread_mutex_t remap_plugin_info::global_list_mutex;
+remap_plugin_info_init instance_of_remap_plugin_info_init;
+
+
+// Initialization
remap_plugin_info_init::remap_plugin_info_init()
{
pthread_mutex_init(&remap_plugin_info::global_list_mutex, 0);
}
-/**
- *
-**/
remap_plugin_info::remap_plugin_info(char *_path)
- :
-next(0),
-path(NULL),
-path_size(0),
-dlh(NULL),
-fp_tsremap_init(NULL),
-fp_tsremap_done(NULL),
-fptsremap_new_instance(NULL),
-fp_tsremap_delete_instance(NULL),
-fp_tsremap_remap(NULL),
-fp_tsremap_os_response(NULL)
+ : next(0), path(NULL), path_size(0), dlh(NULL), fp_tsremap_init(NULL), fp_tsremap_done(NULL), fptsremap_new_instance(NULL),
+ fp_tsremap_delete_instance(NULL), fp_tsremap_remap(NULL), fp_tsremap_os_response(NULL)
{
// coverity did not see xfree
// coverity[ctor_dtor_leak]
@@ -60,10 +46,6 @@ fp_tsremap_os_response(NULL)
}
}
-
-/**
- *
-**/
remap_plugin_info::~remap_plugin_info()
{
xfree(path);
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapPluginInfo.h Thu Sep 16 20:13:19 2010
@@ -52,7 +52,7 @@ class remap_plugin_info
public:
static pthread_mutex_t global_list_mutex;
- Link<remap_plugin_info *>link; //so i can queue these up
+ Link<remap_plugin_info *>link; //so i can queue these up
remap_plugin_info *next;
char *path;
@@ -65,8 +65,8 @@ public:
_tsremap_remap *fp_tsremap_remap;
_tsremap_os_response *fp_tsremap_os_response;
- remap_plugin_info(char *_path);
- ~remap_plugin_info();
+ remap_plugin_info(char *_path);
+ ~remap_plugin_info();
remap_plugin_info *find_by_path(char *_path);
void add_to_list(remap_plugin_info * pi);
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.cc Thu Sep 16 20:13:19 2010
@@ -1,6 +1,6 @@
/** @file
- A brief file description
+ Class to execute one (or more) remap plugin(s).
@section license License
@@ -25,101 +25,45 @@
ClassAllocator<RemapPlugins> pluginAllocator("RemapPluginsAlloc");
-RemapPlugins::RemapPlugins():_cur(0)
-{
-
-}
-
-RemapPlugins::~RemapPlugins()
-{
- _cur = 0;
-}
-
-void
-RemapPlugins::setMap(UrlMappingContainer * m)
-{
- _map_container = m;
-}
-
-void
-RemapPlugins::setRequestUrl(URL * u)
-{
- _request_url = u;
-}
-
-void
-RemapPlugins::setState(HttpTransact::State * state)
-{
- _s = state;
-}
-
-void
-RemapPlugins::setRequestHeader(HTTPHdr * h)
-{
- _request_header = h;
-}
-
-void
-RemapPlugins::setHostHeaderInfo(host_hdr_info * h)
-{
- _hh_ptr = h;
-}
-
int
-RemapPlugins::run_plugin(remap_plugin_info * plugin, char *origURLBuf, int origURLBufSize,
- bool * plugin_modified_host, bool * plugin_modified_port, bool * plugin_modified_path)
+RemapPlugins::run_plugin(remap_plugin_info* plugin, char *origURLBuf, int origURLBufSize,
+ bool* plugin_modified_host, bool* plugin_modified_port, bool* plugin_modified_path)
{
int plugin_retcode;
bool do_x_proto_check = true;
TSRemapRequestInfo rri;
- const char *requestPath;
- int requestPathLen;
int requestPort = 0;
url_mapping *map = _map_container->getMapping();
URL *map_from = &(map->fromURL);
- const char *fromPath;
- int fromPathLen;
URL *map_to = _map_container->getToURL();
- const char *toHost;
- const char *toPath;
- int toPathLen;
- int toHostLen;
-
- const char *fromHost;
- int fromHostLen;
-
- requestPath = _request_url->path_get(&requestPathLen);
- requestPort = _request_url->port_get();
-
+ // The "to" part of the RRI struct always stays the same.
+ rri.remap_to_host = map_to->host_get(&rri.remap_to_host_size);
+ rri.remap_to_port = map_to->port_get();
+ rri.remap_to_path = map_to->path_get(&rri.remap_to_path_size);
+ rri.to_scheme = map_to->scheme_get(&rri.to_scheme_len);
+
+ // These are made to reflect the "defaults" that will be used in
+ // the case where the plugins don't modify them. It's semi-weird
+ // that the "from" and "to" URLs changes when chaining happens, but
+ // it is necessary to get predictable behavior.
if (_cur == 0) {
- fromPath = map_from->path_get(&fromPathLen);
- fromHost = map_from->host_get(&fromHostLen);
- toHost = map_to->host_get(&toHostLen);
- toPath = map_to->path_get(&toPathLen);
+ rri.remap_from_host = map_from->host_get(&rri.remap_from_host_size);
rri.remap_from_port = map_from->port_get();
- rri.remap_to_port = map_to->port_get();
+ rri.remap_from_path = map_from->path_get(&rri.remap_from_path_size);
rri.from_scheme = map_from->scheme_get(&rri.from_scheme_len);
- rri.to_scheme = map_to->scheme_get(&rri.to_scheme_len);
- rri.remap_from_host = map_from->host_get(&rri.remap_from_host_size);
- } else { //after the first plugin has run, we need to use these in order to "chain" them
- fromPath = _request_url->path_get(&fromPathLen);
- fromHost = _request_url->host_get(&fromHostLen);
- toHost = _request_url->host_get(&toHostLen);
- toPath = _request_url->path_get(&toPathLen);
+ } else {
+ rri.remap_from_host = _request_url->host_get(&rri.remap_from_host_size);
rri.remap_from_port = _request_url->port_get();
- rri.remap_to_port = _request_url->port_get();
+ rri.remap_from_path = _request_url->path_get(&rri.remap_from_path_size);
rri.from_scheme = _request_url->scheme_get(&rri.from_scheme_len);
- rri.to_scheme = _request_url->scheme_get(&rri.to_scheme_len);
- rri.remap_from_host = _request_url->host_get(&rri.remap_from_host_size);
}
// Get request port
- rri.request_port = requestPort;
+ rri.request_port = _request_url->port_get();
// Set request path
- rri.request_path = requestPath;
- rri.request_path_size = requestPathLen;
+ rri.request_path = _request_url->path_get(&rri.request_path_size);
// Get request query
rri.request_query = _request_url->query_get(&rri.request_query_size);
@@ -127,18 +71,6 @@ RemapPlugins::run_plugin(remap_plugin_in
// Get request matrix parameters
rri.request_matrix = _request_url->params_get(&rri.request_matrix_size);
- // Get toURL host
- rri.remap_to_host = toHost;
- rri.remap_to_host_size = toHostLen;
-
- // Set "remap from" path
- rri.remap_from_path = fromPath;
- rri.remap_from_path_size = fromPathLen;
-
- // Set "remap to" path
- rri.remap_to_path = toPath;
- rri.remap_to_path_size = toPathLen;
-
rri.size = sizeof(rri);
rri.orig_url = origURLBuf;
rri.orig_url_size = origURLBufSize;
@@ -155,6 +87,7 @@ RemapPlugins::run_plugin(remap_plugin_in
// Get request Host
rri.request_host = _request_url->host_get(&rri.request_host_size);
+
// Copy client IP address
rri.client_ip = _s ? _s->client_info.ip : 0;
@@ -277,8 +210,9 @@ RemapPlugins::run_plugin(remap_plugin_in
int
RemapPlugins::run_single_remap()
{
- Debug("url_rewrite", "Running single remap rule for the %d%s time", _cur, _cur == 1 ? "st" : _cur == 2 ? "nd" : _cur == 3 ? "rd" : "th" //i should patent this
- );
+ // I should patent this
+ Debug("url_rewrite", "Running single remap rule for the %d%s time", _cur, _cur == 1 ? "st" : _cur == 2 ? "nd" : _cur == 3 ? "rd" : "th");
+
remap_plugin_info *plugin = NULL;
bool plugin_modified_host = false;
@@ -291,16 +225,12 @@ RemapPlugins::run_single_remap()
int origURLBufSize;
const char *requestPath;
int requestPathLen;
- int requestPort;
url_mapping *map = _map_container->getMapping();
URL *map_from = &(map->fromURL);
const char *fromPath;
int fromPathLen;
URL *map_to = _map_container->getToURL();
- const char *fromHost;
- int fromHostLen;
-
const char *toHost;
const char *toPath;
int toPathLen;
@@ -312,39 +242,27 @@ RemapPlugins::run_single_remap()
bool debug_on = false;
int retcode = 0; // 0 - no redirect, !=0 - redirected
- if (_cur == 0 && _s) { // it is important - we must copy "no_negative_cache" flag before possible plugin call [only do this on our first iteration of this function]
+ // it is important - we must copy "no_negative_cache" flag before possible plugin call [only do this on our first iteration of this function]
+ if (_cur == 0 && _s) {
_s->no_negative_cache = map->no_negative_cache;
_s->pristine_host_hdr = map->pristine_host_hdr;
_s->remap_chunking_enabled = map->chunking_enabled;
}
requestPath = _request_url->path_get(&requestPathLen);
- requestPort = _request_url->port_get();
- int fromPort = 0;
- int toPort = 0;
+ toHost = map_to->host_get(&toHostLen);
+ toPath = map_to->path_get(&toPathLen);
+ // after the first plugin has run, we need to use these in order to "chain" them and previous changes are all in _request_url,
+ // in case we need to copy values from previous plugin or from the remap rule.
if (_cur == 0) {
fromPath = map_from->path_get(&fromPathLen);
- fromHost = map_from->host_get(&fromHostLen);
- toHost = map_to->host_get(&toHostLen);
- toPath = map_to->path_get(&toPathLen);
- fromPort = map_from->port_get();
- toPort = map_to->port_get();
- } else { //after the first plugin has run, we need to use these in order to "chain" them and previous changes are all in _request_url
- fromHost = _request_url->host_get(&fromHostLen);
+ } else {
fromPath = _request_url->path_get(&fromPathLen);
- toHost = _request_url->host_get(&toHostLen);
- toPath = _request_url->path_get(&toPathLen);
- toPort = _request_url->port_get();
- fromPort = _request_url->port_get();
}
- Debug("url_rewrite", "before remap plugin: from: scheme://%.*s:%d/%.*s *to* scheme://%.*s:%d/%.*s",
- fromHostLen, fromHost, fromPort, fromPathLen, fromPath, toHostLen, toHost, toPort, toPathLen, toPath);
-
- if (is_debug_tag_set("url_rewrite"))
- debug_on = true;
+ debug_on = is_debug_tag_set("url_rewrite");
if (_request_header)
plugin = map->get_plugin(_cur); //get the nth plugin in our list of plugins
@@ -352,7 +270,7 @@ RemapPlugins::run_single_remap()
if (plugin || debug_on) {
origURLBuf = _request_url->string_get(NULL);
origURLBufSize = strlen(origURLBuf);
- Debug("url_rewrite", "string is: %s", origURLBuf);
+ Debug("url_rewrite", "Original request URL is : %s", origURLBuf);
}
if (plugin) {
@@ -522,26 +440,16 @@ RemapPlugins::run_single_remap()
}
done:
- int requestHostLen = 0;
- const char *requestHost = _request_url->host_get(&requestHostLen);
- requestPort = _request_url->port_get();
- requestPath = _request_url->path_get(&requestPathLen);
-
- Debug("url_rewrite", "after remap plugin: request url now: scheme://%.*s:%d/%.*s",
- requestHostLen, requestHost, requestPort, requestPathLen, requestPath);
-
- if (_cur > 10) {
+ if (_cur > MAX_REMAP_PLUGIN_CHAIN) {
Error("Are you serious?! Called run_single_remap more than 10 times. Stopping this remapping insanity now");
Debug("url_rewrite",
"Are you serious?! Called run_single_remap more than 10 times. Stopping this remapping insanity now");
return 1;
}
- _cur++; //important
-
- if (_cur >= map->_plugin_count) {
+ if (++_cur >= map->_plugin_count) {
//normally, we would callback into this function but we dont have anything more to do!
- Debug("url_rewrite", "we exhausted all available plugins");
+ Debug("url_rewrite", "We completed all remap plugins for this rule");
return 1;
} else {
Debug("url_rewrite", "Completed single remap. Attempting another via immediate callback");
@@ -552,7 +460,7 @@ done:
}
int
-RemapPlugins::run_remap(int event, Event * e)
+RemapPlugins::run_remap(int event, Event* e)
{
Debug("url_rewrite", "Inside RemapPlugins::run_remap with cur = %d", _cur);
@@ -561,7 +469,7 @@ RemapPlugins::run_remap(int event, Event
int ret = 0;
- //EThread * t = mutex->thread_holding;
+ //EThread* t = mutex->thread_holding;
/* make sure we weren't cancelled */
if (action.cancelled) {
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapPlugins.h Thu Sep 16 20:13:19 2010
@@ -1,6 +1,6 @@
/** @file
- A brief file description
+ Declarations for the RemapPlugins class.
@section license License
@@ -36,30 +36,39 @@
#include "HttpTransact.h"
#include "ReverseProxy.h"
+static const unsigned int MAX_REMAP_PLUGIN_CHAIN = 10;
+
/**
* A class that represents a queue of plugins to run
**/
struct RemapPlugins: public Continuation
{
- unsigned int _cur;
- UrlMappingContainer *_map_container;
- URL *_request_url;
- HTTPHdr *_request_header;
- HttpTransact::State * _s;
- host_hdr_info *_hh_ptr;
-
- RemapPlugins();
- ~RemapPlugins();
+ RemapPlugins()
+ : _cur(0)
+ { }
+
+ ~RemapPlugins() { _cur = 0; }
+
+ // Some basic setters
+ void setMap(UrlMappingContainer* m) { _map_container = m; }
+ void setRequestUrl(URL* u) { _request_url = u; }
+ void setState(HttpTransact::State* state) { _s = state; }
+ void setRequestHeader(HTTPHdr* h) { _request_header = h; }
+ void setHostHeaderInfo(host_hdr_info* h) { _hh_ptr = h; }
int run_remap(int, Event *);
int run_single_remap();
- void setMap(UrlMappingContainer *);
- void setRequestUrl(URL *);
- void setRequestHeader(HTTPHdr *);
int run_plugin(remap_plugin_info *, char *, int, bool *, bool *, bool *);
- void setState(HttpTransact::State *);
- void setHostHeaderInfo(host_hdr_info *);
+
Action action;
+
+ private:
+ unsigned int _cur;
+ UrlMappingContainer *_map_container;
+ URL *_request_url;
+ HTTPHdr *_request_header;
+ HttpTransact::State * _s;
+ host_hdr_info *_hh_ptr;
};
#endif
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.cc Thu Sep 16 20:13:19 2010
@@ -241,7 +241,7 @@ RemapProcessor::finish_remap(HttpTransac
&old_host_hdr_len);
if (old_host_hdr) {
old_host_hdr = xstrndup(old_host_hdr, old_host_hdr_len);
- Debug("url_rewrite", "Host Header before rewrite %s", old_host_hdr);
+ Debug("url_rewrite", "Host: Header before rewrite %.*s", old_host_hdr_len, old_host_hdr);
xfree(old_host_hdr);
}
}
@@ -265,9 +265,9 @@ RemapProcessor::finish_remap(HttpTransac
// through
if (tmp >= host_buf_len) {
request_header->field_delete(MIME_FIELD_HOST, MIME_LEN_HOST);
- Debug("url_rewrite", "Host Header too long after rewrite");
+ Debug("url_rewrite", "Host: Header too long after rewrite");
} else {
- Debug("url_rewrite", "Host Header after rewrite %s", host_hdr_buf);
+ Debug("url_rewrite", "Host: Header after rewrite %.*s", tmp, host_hdr_buf);
request_header->value_set(MIME_FIELD_HOST, MIME_LEN_HOST, host_hdr_buf, tmp);
}
}
@@ -314,19 +314,9 @@ RemapProcessor::perform_remap(Continuati
} else {
ink_debug_assert(cont->mutex->thread_holding == this_ethread());
plugins->mutex = cont->mutex;
- plugins->action = cont; //make sure the HTTP SM gets the callback
+ plugins->action = cont;
SET_CONTINUATION_HANDLER(plugins, &RemapPlugins::run_remap);
eventProcessor.schedule_imm(plugins, _ET_REMAP);
return &plugins->action;
}
}
-
-RemapProcessor::RemapProcessor():_ET_REMAP(0), _use_separate_remap_thread(false)
-{
-
-}
-
-RemapProcessor::~RemapProcessor()
-{
-
-}
Modified: trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/RemapProcessor.h Thu Sep 16 20:13:19 2010
@@ -43,23 +43,20 @@ class RemapProcessor: public Processor
{
public:
+ RemapProcessor()
+ :_ET_REMAP(0), _use_separate_remap_thread(false)
+ { }
+
+ ~RemapProcessor() { }
+
bool setup_for_remap(HttpTransact::State * s);
bool finish_remap(HttpTransact::State * s);
Action *perform_remap(Continuation * cont, HttpTransact::State * s);
int start(int num_threads);
- RemapProcessor();
- ~RemapProcessor();
bool LessThan(HttpTransact::State *, HttpTransact::State *);
- void setUseSeparateThread()
- {
- _use_separate_remap_thread = true;
- }
-
- bool using_separate_thread()
- {
- return (_use_separate_remap_thread == true);
- }
+ void setUseSeparateThread() { _use_separate_remap_thread = true; }
+ bool using_separate_thread() { return _use_separate_remap_thread == true; }
private:
EventType _ET_REMAP;
Modified: trafficserver/traffic/trunk/proxy/http2/remap/StringHash.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/StringHash.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/StringHash.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/StringHash.cc Thu Sep 16 20:13:19 2010
@@ -22,7 +22,6 @@
*/
#include "StringHash.h"
-#include "Main.h"
#include "Error.h"
@@ -37,8 +36,6 @@ StringHash::StringHash(int _hash_size, b
hash_mask_size = 0;
max_hit_level = 0;
- //printf("StringHash::StringHash(0x%0X,%s)\n",_hash_size,_ignore_case ? "ignore case" : "count case");
-
if ((hash_size = _hash_size) < STRINGHASH_MIN_TBL_SIZE)
_hash_size = (hash_size = STRINGHASH_MIN_TBL_SIZE);
if (_hash_size > STRINGHASH_MAX_TBL_SIZE)
@@ -188,20 +185,6 @@ StringHashEntry & StringHashEntry::clean
return *this;
}
-StringHashEntry::StringHashEntry()
-{
- next = NULL;
- hashid = 0;
- hash_table_index = (strsize = 0);
- str = NULL;
- ptr = NULL;
-}
-
-StringHashEntry::~StringHashEntry()
-{
- clean();
-}
-
const char *
StringHashEntry::setstr(const char *_str, int _strsize)
{
Modified: trafficserver/traffic/trunk/proxy/http2/remap/StringHash.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/StringHash.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/StringHash.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/StringHash.h Thu Sep 16 20:13:19 2010
@@ -24,6 +24,8 @@
#ifndef _STRING_HASH_H_
#define _STRING_HASH_H_
+#include "ink_port.h"
+
#define STRINGHASH_MIN_TBL_SIZE 0x10
#define STRINGHASH_MAX_TBL_SIZE 0x1000000
@@ -40,9 +42,14 @@ public:
char *str;
void *ptr;
- StringHashEntry();
- ~StringHashEntry();
- StringHashEntry & clean();
+ StringHashEntry()
+ : next(NULL), hashid(0), hash_table_index(0), strsize(0), str(NULL), ptr(NULL)
+ { }
+
+ ~StringHashEntry() { clean(); }
+
+ StringHashEntry& clean();
+
const char *setstr(const char *_str, int _strsize = (-1));
};
@@ -59,12 +66,14 @@ public:
bool ignore_case;
StringHashEntry **hash;
- StringHash(int _hash_size = 0x1000, bool _ignore_case = false);
- ~StringHash();
+ StringHash(int _hash_size = 0x1000, bool _ignore_case = false);
+ ~StringHash();
+
private:
unsigned long csum_calc(void *_buf, int size);
+
public:
- StringHashEntry * find_or_add(void *_ptr, const char *str, int strsize = (-1));
+ StringHashEntry * find_or_add(void *_ptr, const char *str, int strsize = (-1));
};
#endif
Modified: trafficserver/traffic/trunk/proxy/http2/remap/Trie.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/Trie.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/Trie.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/Trie.h Thu Sep 16 20:13:19 2010
@@ -41,14 +41,12 @@ public:
// will return false if not found; else value_ptr will point to found value
bool Search(const char *key, T *&value_ptr, int key_len = -1);
-
void Clear();
typedef std::list<T*> ValuePointerList;
const ValuePointerList &GetValues() const { return m_value_list; }
- virtual ~Trie() { Clear(); };
-
+ virtual ~Trie() { Clear(); }
private:
static const int N_NODE_CHILDREN = 256;
@@ -59,14 +57,17 @@ private:
T value;
bool occupied;
int rank;
+
void Clear() {
occupied = false;
rank = 0;
bzero(children, sizeof(Node *) * N_NODE_CHILDREN);
- };
+ }
+
void Print(const char *debug_tag) const;
- inline Node* GetChild(char index) const { return children[static_cast<unsigned char>(index)]; };
- inline void SetChild(char index, Node *child) { children[static_cast<unsigned char>(index)] = child; };
+ inline Node* GetChild(char index) const { return children[static_cast<unsigned char>(index)]; }
+ inline void SetChild(char index, Node *child) { children[static_cast<unsigned char>(index)] = child; }
+
private:
Node *children[N_NODE_CHILDREN];
};
@@ -180,14 +181,17 @@ Trie<T>::Search(const char *key, T *&val
value_ptr = &(found_node->value);
return true;
}
+
return false;
}
+
template<typename T>
void
Trie<T>::_Clear(Node *node)
{
Node *child;
+
for (int i = 0; i < N_NODE_CHILDREN; ++i) {
child = node->GetChild(i);
if (child) {
@@ -216,6 +220,7 @@ Trie<T>::Node::Print(const char *debug_t
} else {
Debug(debug_tag, "Node is not occupied");
}
+
for (int i = 0; i < N_NODE_CHILDREN; ++i) {
if (GetChild(i)) {
Debug(debug_tag, "Node has child for char %c", static_cast<char>(i));
Modified: trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.cc Thu Sep 16 20:13:19 2010
@@ -31,7 +31,7 @@ url_mapping::url_mapping(int rank /* = 0
optional_referer(false), negative_referer(false), no_negative_cache(false), wildcard_from_scheme(false),
pristine_host_hdr(-1), chunking_enabled(-1), tag(NULL), filter_redirect_url(NULL), referer_list(0),
redir_chunk_list(0), filter(NULL), _plugin_count(0), _cur_instance_count(0), _rank(rank), _default_to_url()
-{ /* nop */ ;
+{
}
@@ -53,6 +53,9 @@ remap_plugin_info *
url_mapping::get_plugin(unsigned int index)
{
Debug("url_rewrite", "get_plugin says we have %d plugins and asking for plugin %d", _plugin_count, index);
+ if (_plugin_count == 0)
+ return NULL;
+
remap_plugin_info *plugin = NULL;
if (unlikely(index > _plugin_count)) {
@@ -69,6 +72,7 @@ url_mapping::get_plugin(unsigned int ind
}
j++;
}
+
Debug("url_rewrite", "url_mapping::get_plugin could not find requested plugin");
return NULL;
}
@@ -79,8 +83,7 @@ url_mapping::get_plugin(unsigned int ind
**/
bool url_mapping::set_instance(remap_plugin_info * p, ihandle * h)
{
- Debug("url_rewrite", "Adding handle: %x to instance map for plugin: %x (%s) [cur:%d]", h, p, p->path,
- _cur_instance_count);
+ Debug("url_rewrite", "Adding handle: %x to instance map for plugin: %x (%s) [cur:%d]", h, p, p->path, _cur_instance_count);
_instance_map[p] = h;
return true;
}
Modified: trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/UrlMapping.h Thu Sep 16 20:13:19 2010
@@ -61,11 +61,11 @@ public:
class redirect_tag_str
{
public:
- redirect_tag_str():next(0), chunk_str(NULL), type(0)
- {
- }
+ redirect_tag_str()
+ : next(0), chunk_str(NULL), type(0)
+ { }
- ~redirect_tag_str()
+ ~redirect_tag_str()
{
type = 0;
if (chunk_str) {
@@ -118,9 +118,9 @@ public:
int getRank() const { return _rank; };
private:
- bool set_instance(remap_plugin_info *, ihandle *);
- std::deque<remap_plugin_info *>_plugin_list;
- std::map<remap_plugin_info *, ihandle *>_instance_map;
+ bool set_instance(remap_plugin_info *, ihandle *);
+ std::deque<remap_plugin_info *>_plugin_list;
+ std::map<remap_plugin_info *, ihandle *>_instance_map;
int _cur_instance_count;
int _rank;
URL _default_to_url;
@@ -131,17 +131,23 @@ private:
class UrlMappingContainer {
-
public:
+ UrlMappingContainer()
+ : _mapping(NULL), _toURLPtr(NULL), _heap(NULL)
+ { }
+
+ UrlMappingContainer(url_mapping *m)
+ : _heap(NULL)
+ { set(m); }
- UrlMappingContainer() : _mapping(NULL), _toURLPtr(NULL), _heap(NULL) { };
+ UrlMappingContainer(HdrHeap *heap)
+ : _mapping(NULL), _toURLPtr(NULL), _heap(heap)
+ { }
- UrlMappingContainer(url_mapping *m) : _heap(NULL) { set(m); };
- UrlMappingContainer(HdrHeap *heap) : _mapping(NULL), _toURLPtr(NULL), _heap(heap) { };
+ ~UrlMappingContainer() { deleteToURL(); }
URL *getToURL() const { return _toURLPtr; };
-
url_mapping *getMapping() const { return _mapping; };
void set(url_mapping *m) {
@@ -175,10 +181,7 @@ public:
_heap = NULL;
}
- ~UrlMappingContainer() { deleteToURL(); };
-
private:
-
url_mapping *_mapping;
URL *_toURLPtr;
URL _toURL;
@@ -187,7 +190,6 @@ private:
// non-copyable, non-assignable
UrlMappingContainer(const UrlMappingContainer &orig);
UrlMappingContainer &operator =(const UrlMappingContainer &rhs);
-
};
#endif
Modified: trafficserver/traffic/trunk/proxy/http2/remap/UrlMappingPathIndex.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/UrlMappingPathIndex.h?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/UrlMappingPathIndex.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/UrlMappingPathIndex.h Thu Sep 16 20:13:19 2010
@@ -34,7 +34,8 @@
class UrlMappingPathIndex
{
public:
- UrlMappingPathIndex() { };
+ UrlMappingPathIndex()
+ { }
bool Insert(url_mapping *mapping);
@@ -46,26 +47,22 @@ public:
void Clear();
- virtual ~UrlMappingPathIndex()
- {
- Clear();
- }
+ virtual ~UrlMappingPathIndex() { Clear(); }
private:
typedef Trie<url_mapping *> UrlMappingTrie;
- struct UrlMappingTrieKey
- {
+ struct UrlMappingTrieKey {
int scheme_wks_idx;
int port;
+
UrlMappingTrieKey(int idx, int p) : scheme_wks_idx(idx), port(p) { };
- bool operator <(const UrlMappingTrieKey &rhs) const
- {
+ bool operator <(const UrlMappingTrieKey &rhs) const {
if (scheme_wks_idx == rhs.scheme_wks_idx) {
return (port < rhs.port);
}
return (scheme_wks_idx < rhs.scheme_wks_idx);
- };
+ }
};
typedef std::map<UrlMappingTrieKey, UrlMappingTrie *> UrlMappingGroup;
@@ -76,8 +73,7 @@ private:
UrlMappingPathIndex(const UrlMappingPathIndex &rhs) { NOWARN_UNUSED(rhs); };
UrlMappingPathIndex &operator =(const UrlMappingPathIndex &rhs) { NOWARN_UNUSED(rhs); return *this; }
- inline UrlMappingTrie *_GetTrie(URL *url, int &idx, int port, bool search = true) const
- {
+ inline UrlMappingTrie *_GetTrie(URL *url, int &idx, int port, bool search = true) const {
idx = url->scheme_get_wksidx();
UrlMappingGroup::const_iterator group_iter;
if (search) { // normal search
@@ -90,7 +86,7 @@ private:
return group_iter->second;
}
return 0;
- };
+ }
};
Modified: trafficserver/traffic/trunk/proxy/http2/remap/UrlRewrite.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/remap/UrlRewrite.cc?rev=997909&r1=997908&r2=997909&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/remap/UrlRewrite.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/remap/UrlRewrite.cc Thu Sep 16 20:13:19 2010
@@ -498,10 +498,10 @@ process_filter_opt(url_mapping * mp, BUI
UrlRewrite::UrlRewrite(const char *file_var_in)
-:nohost_rules(0), reverse_proxy(0), pristine_host_hdr(0), backdoor_enabled(0),
-mgmt_autoconf_port(0), default_to_pac(0), default_to_pac_port(0), file_var(NULL), ts_name(NULL),
-http_default_redirect_url(NULL), num_rules_forward(0), num_rules_reverse(0), num_rules_redirect_permanent(0),
-num_rules_redirect_temporary(0), remap_pi_list(NULL)
+ : nohost_rules(0), reverse_proxy(0), pristine_host_hdr(0), backdoor_enabled(0),
+ mgmt_autoconf_port(0), default_to_pac(0), default_to_pac_port(0), file_var(NULL), ts_name(NULL),
+ http_default_redirect_url(NULL), num_rules_forward(0), num_rules_reverse(0), num_rules_redirect_permanent(0),
+ num_rules_redirect_temporary(0), remap_pi_list(NULL)
{
forward_mappings.hash_lookup = reverse_mappings.hash_lookup =
@@ -1064,8 +1064,8 @@ UrlRewrite::PerformACLFiltering(HttpTran
bool
- UrlRewrite::Remap(HttpTransact::State * s, HTTPHdr * request_header,
- char **redirect_url, char **orig_url, char *tag, unsigned int filter_mask)
+UrlRewrite::Remap(HttpTransact::State * s, HTTPHdr * request_header,
+ char **redirect_url, char **orig_url, char *tag, unsigned int filter_mask)
{
URL *request_url = NULL;
bool mapping_found;
@@ -1094,6 +1094,9 @@ bool
ink_assert(forward_mappings.empty());
return false;
}
+
+ Debug("url_rewrite", "Starting ::Remap()");
+
// Since are called before request validity checking
// occurs, make sure that we have both a valid request
// header and a valid URL