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/03/15 22:44:38 UTC

svn commit: r923450 - in /incubator/trafficserver/traffic/branches/2.0.x: ./ STATUS libinktomi++/ink_snprintf.cc proxy/http2/remap/UrlMappingPathIndex.cc proxy/http2/remap/UrlMappingPathIndex.h proxy/http2/remap/UrlRewrite.cc

Author: zwoop
Date: Mon Mar 15 21:44:38 2010
New Revision: 923450

URL: http://svn.apache.org/viewvc?rev=923450&view=rev
Log:
TS-237: catch-all remap rule ("map / ....") stopped working after lookup optimizations

Merged from "trunk".

Modified:
    incubator/trafficserver/traffic/branches/2.0.x/   (props changed)
    incubator/trafficserver/traffic/branches/2.0.x/STATUS
    incubator/trafficserver/traffic/branches/2.0.x/libinktomi++/ink_snprintf.cc   (props changed)
    incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.cc
    incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.h
    incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlRewrite.cc

Propchange: incubator/trafficserver/traffic/branches/2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 15 21:44:38 2010
@@ -1 +1 @@
-/incubator/trafficserver/traffic/trunk:921639
+/incubator/trafficserver/traffic/trunk:921639,921965

Modified: incubator/trafficserver/traffic/branches/2.0.x/STATUS
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/branches/2.0.x/STATUS?rev=923450&r1=923449&r2=923450&view=diff
==============================================================================
--- incubator/trafficserver/traffic/branches/2.0.x/STATUS (original)
+++ incubator/trafficserver/traffic/branches/2.0.x/STATUS Mon Mar 15 21:44:38 2010
@@ -49,12 +49,6 @@ For the final 2.0.0 ATS release, see the
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
 
-  * core: catch-all remap rule ("map / ....") stopped working after lookup
-    optimizations.
-    Trunk patch: http://svn.apache.org/viewvc?rev=921965&view=rev
-    Jira: https://issues.apache.org/jira/browse/TS-237
-    +1: manjesh, zwoop, sjiang, jplevyak, georgep
-
   * API: Bump remap API major version
     Trunk patch: http://svn.apache.org/viewvc?rev=922056&view=rev
     Jira: https://issues.apache.org/jira/browse/TS-238

Propchange: incubator/trafficserver/traffic/branches/2.0.x/libinktomi++/ink_snprintf.cc
            ('svn:mergeinfo' removed)

Modified: incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.cc?rev=923450&r1=923449&r2=923450&view=diff
==============================================================================
--- incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.cc (original)
+++ incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.cc Mon Mar 15 21:44:38 2010
@@ -25,18 +25,19 @@
 bool
 UrlMappingPathIndex::Insert(url_mapping *mapping)
 {
-  URLType url_type;
+  int scheme_idx;
   int port = (mapping->fromURL).port_get();
   UrlMappingTrie *trie;
   int from_path_len;
   const char *from_path;
 
-  trie = _GetTrie(&(mapping->fromURL), url_type, port);
+  trie = _GetTrie(&(mapping->fromURL), scheme_idx, port);
   
   if (!trie) {
     trie = new UrlMappingTrie();
-    m_tries.insert(UrlMappingGroup::value_type(UrlMappingTrieKey(url_type, port), trie));
-    Debug("UrlMappingPathIndex::Insert", "Created new trie for url type, port combo <%d, %d>", url_type, port);
+    m_tries.insert(UrlMappingGroup::value_type(UrlMappingTrieKey(scheme_idx, port), trie));
+    Debug("UrlMappingPathIndex::Insert", "Created new trie for scheme index, port combo <%d, %d>",
+          scheme_idx, port);
   }
   
   from_path = mapping->fromURL.path_get(&from_path_len);
@@ -49,19 +50,19 @@ UrlMappingPathIndex::Insert(url_mapping 
 }
 
 url_mapping *
-UrlMappingPathIndex::Search(URL *request_url, int request_port) const
+UrlMappingPathIndex::Search(URL *request_url, int request_port, bool normal_search /* = true */) const
 {
   url_mapping **retval = 0;
-  URLType url_type;
+  int scheme_idx;
   UrlMappingTrie *trie;
   int path_len;
   const char *path;
 
-  trie = _GetTrie(request_url, url_type, request_port);
+  trie = _GetTrie(request_url, scheme_idx, request_port, normal_search);
   
   if (!trie) {
-    Debug("UrlMappingPathIndex::Search", "No mappings exist for url type, port combo <%d, %d>",
-          url_type, request_port);
+    Debug("UrlMappingPathIndex::Search", "No mappings exist for scheme index, port combo <%d, %d>",
+          scheme_idx, request_port);
     goto lFail;
   }
 

Modified: incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.h?rev=923450&r1=923449&r2=923450&view=diff
==============================================================================
--- incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.h (original)
+++ incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlMappingPathIndex.h Mon Mar 15 21:44:38 2010
@@ -38,7 +38,7 @@ public:
 
   bool Insert(url_mapping *mapping);
 
-  url_mapping *Search(URL *request_url, int request_port) const;
+  url_mapping *Search(URL *request_url, int request_port, bool normal_search = true) const;
 
   typedef std::list<url_mapping *> MappingList;
   
@@ -56,15 +56,15 @@ private:
   typedef Trie<url_mapping *> UrlMappingTrie;
   struct UrlMappingTrieKey 
   {
-    URLType url_type;
+    int scheme_wks_idx;
     int port;
-    UrlMappingTrieKey(URLType type, int p) : url_type(type), port(p) { };
+    UrlMappingTrieKey(int idx, int p) : scheme_wks_idx(idx), port(p) { };
     bool operator <(const UrlMappingTrieKey &rhs) const 
     {
-      if (url_type == rhs.url_type) {
+      if (scheme_wks_idx == rhs.scheme_wks_idx) {
         return (port < rhs.port);
       }
-      return (url_type < rhs.url_type);
+      return (scheme_wks_idx < rhs.scheme_wks_idx);
     };
   };
   
@@ -76,10 +76,16 @@ private:
   UrlMappingPathIndex(const UrlMappingPathIndex &rhs) { };
   UrlMappingPathIndex &operator =(const UrlMappingPathIndex &rhs) { return *this; }
 
-  inline UrlMappingTrie *_GetTrie(URL *url, URLType &url_type, int port) const
+  inline UrlMappingTrie *_GetTrie(URL *url, int &idx, int port, bool search = true) const
   {
-    url_type = static_cast<URLType>(url->type_get());
-    UrlMappingGroup::const_iterator group_iter = m_tries.find(UrlMappingTrieKey(url_type, port));
+    idx = url->scheme_get_wksidx();
+    UrlMappingGroup::const_iterator group_iter;
+    if (search) { // normal search
+      group_iter = m_tries.find(UrlMappingTrieKey(idx, port));
+    } else { // return the first trie arbitrarily
+      Debug("UrlMappingPathIndex::_GetTrie", "Not performing search; will return first available trie");
+      group_iter = m_tries.begin();
+    }
     if (group_iter != m_tries.end()) {
       return group_iter->second;
     }

Modified: incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlRewrite.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlRewrite.cc?rev=923450&r1=923449&r2=923450&view=diff
==============================================================================
--- incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlRewrite.cc (original)
+++ incubator/trafficserver/traffic/branches/2.0.x/proxy/http2/remap/UrlRewrite.cc Mon Mar 15 21:44:38 2010
@@ -743,7 +743,8 @@ UrlRewrite::_tableLookup(InkHashTable * 
   ht_result = ink_hash_table_lookup(h_table, request_host, (void **) &ht_entry);
 
   if (likely(ht_result && ht_entry)) {
-    um = ht_entry->Search(request_url, request_port);
+    // for empty host don't do a normal search, get a mapping arbitrarily
+    um = ht_entry->Search(request_url, request_port, request_host_len ? true : false);
   }
   return um;
 }