trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1210237 - in /trafficserver/traffic/branches/3.0.x: ./ CHANGES STATUS proxy/hdrs/HdrToken.cc proxy/hdrs/MIME.cc
Date Sun, 04 Dec 2011 21:44:52 GMT
Author: igalic
Date: Sun Dec  4 21:44:52 2011
New Revision: 1210237

URL: http://svn.apache.org/viewvc?rev=1210237&view=rev
Log:
promote

Modified:
    trafficserver/traffic/branches/3.0.x/   (props changed)
    trafficserver/traffic/branches/3.0.x/CHANGES
    trafficserver/traffic/branches/3.0.x/STATUS
    trafficserver/traffic/branches/3.0.x/proxy/hdrs/HdrToken.cc
    trafficserver/traffic/branches/3.0.x/proxy/hdrs/MIME.cc

Propchange: trafficserver/traffic/branches/3.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec  4 21:44:52 2011
@@ -1,4 +1,4 @@
 /incubator/trafficserver/traffic/branches/dev:891823-915885
 /trafficserver/traffic/branches/ts-291:965529-991993
 /trafficserver/traffic/branches/wccp:1021790-1040544
-/trafficserver/traffic/trunk:1129268,1131080,1131473,1133066,1133071,1133639,1135769-1135770,1136958,1137111,1137775,1137844,1137846,1142523,1143116,1144094,1144096,1144746,1146414,1152536,1153236,1154744,1155125,1171365,1175914,1196822,1196922
+/trafficserver/traffic/trunk:1129268,1131080,1131473,1133066,1133071,1133639,1135769-1135770,1136958,1137111,1137775,1137844,1137846,1142523,1143116,1144094,1144096,1144746,1146414,1152536,1153236,1154744,1155125,1171365,1175914,1196822,1196922,1209291

Modified: trafficserver/traffic/branches/3.0.x/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/3.0.x/CHANGES?rev=1210237&r1=1210236&r2=1210237&view=diff
==============================================================================
--- trafficserver/traffic/branches/3.0.x/CHANGES (original)
+++ trafficserver/traffic/branches/3.0.x/CHANGES Sun Dec  4 21:44:52 2011
@@ -1,8 +1,14 @@
                                                          -*- coding: utf-8 -*-
-
 Changes with Apache Traffic Server 3.0.2
+  *) [TS-1030] Improve hashing mechanism on WKS.
+
   *) [TS-1011]: SSL doesn't work on Solaris.
 
+  *) [TS-1028] Avoid triggering assert when running debug build and enabling
+   per-thread connection pols
+
+  *) [TS-1021] Remove extra newline from binary logs.
+
   *) [TS-1013]: Allow ssl_multicert.config to support CA chains per host
 
   *) [TS-944]: ssl.server.cert.path & ssl.server.private_key.path do not work as expected

Modified: trafficserver/traffic/branches/3.0.x/STATUS
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/3.0.x/STATUS?rev=1210237&r1=1210236&r2=1210237&view=diff
==============================================================================
--- trafficserver/traffic/branches/3.0.x/STATUS (original)
+++ trafficserver/traffic/branches/3.0.x/STATUS Sun Dec  4 21:44:52 2011
@@ -39,6 +39,10 @@ A list of all bugs open for the next v3.
 
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
 
+  *) HTTP: Poor hashing on WKS's (well-known-string's)
+   Trunk patch: http://svn.apache.org/viewvc?view=rev&rev=1209291
+   Jira: https://issues.apache.org/jira/browse/TS-1030
+   +1: zwoop, igalic, zym
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
   [ New proposals should be added at the end of the list ]
@@ -53,11 +57,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK:
      this patch to be merge later and leave some time for us to find out how to
      fix it. we are now testing the fix.
 
-  *) HTTP: Poor hashing on WKS's (well-known-string's)
-   Trunk patch: http://svn.apache.org/viewvc?view=rev&rev=1209291
-   Jira: https://issues.apache.org/jira/browse/TS-1030
-   +1: zwoop, igalic, zym
-
 RELEASE PROCESS
 
 The Traffic Server release process is documented at

Modified: trafficserver/traffic/branches/3.0.x/proxy/hdrs/HdrToken.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/3.0.x/proxy/hdrs/HdrToken.cc?rev=1210237&r1=1210236&r2=1210237&view=diff
==============================================================================
--- trafficserver/traffic/branches/3.0.x/proxy/hdrs/HdrToken.cc (original)
+++ trafficserver/traffic/branches/3.0.x/proxy/hdrs/HdrToken.cc Sun Dec  4 21:44:52 2011
@@ -336,27 +336,36 @@ DFA *hdrtoken_strs_dfa = NULL;
 struct HdrTokenHashBucket
 {
   const char *wks;
+  uint32_t hash;
 };
 
 HdrTokenHashBucket hdrtoken_hash_table[HDRTOKEN_HASH_TABLE_SIZE];
 
-#define TINY_MASK(x) (((u_int32_t)1<<(x))-1)
-
 /**
   basic FNV hash
 **/
-inline unsigned int
+#define TINY_MASK(x) (((u_int32_t)1<<(x))-1)
+
+inline uint32_t
+hash_to_slot(uint32_t hash)
+{
+  return ((hash>>15) ^ hash) & TINY_MASK(15);
+}
+
+inline uint32_t
 hdrtoken_hash(const unsigned char *string, unsigned int length)
 {
-  const uint32_t InitialFNV = 2166136261U;
-  const int32_t FNVMultiple = 16777619;
+  static const uint32_t InitialFNV = 2166136261U;
+  static const int32_t FNVMultiple = 16777619;
 
   uint32_t hash = InitialFNV;
-  for(size_t i = 0; i < length; i++)  {
+
+  for (size_t i = 0; i < length; i++)  {
       hash = hash ^ (toupper(string[i])); 
       hash = hash * FNVMultiple;          
   }
-  return (((hash>>15) ^ hash) & TINY_MASK(15));
+
+  return hash;
 }
 
 /*-------------------------------------------------------------------------
@@ -498,7 +507,6 @@ const char *_hdrtoken_commonly_tokenized
   // Header extensions
   "X-Forwarded-For",
   "TE",
-  
 };
 
 /*-------------------------------------------------------------------------
@@ -507,14 +515,12 @@ const char *_hdrtoken_commonly_tokenized
 void
 hdrtoken_hash_init()
 {
-  unsigned int i;
+  uint32_t i;
   int num_collisions;
 
-  for (i = 0; i < HDRTOKEN_HASH_TABLE_SIZE; i++) {
-    hdrtoken_hash_table[i].wks = NULL;
-  }
-
+  memset(hdrtoken_hash_table, 0, sizeof(hdrtoken_hash_table));
   num_collisions = 0;
+
   for (i = 0; i < (int) SIZEOF(_hdrtoken_commonly_tokenized_strs); i++) {
     // convert the common string to the well-known token
     unsigned const char *wks;
@@ -523,14 +529,18 @@ hdrtoken_hash_init()
                                         (const char **) &wks);
     ink_release_assert(wks_idx >= 0);
 
-    unsigned int slot = hdrtoken_hash(wks, hdrtoken_str_lengths[wks_idx]);
+    uint32_t hash = hdrtoken_hash(wks, hdrtoken_str_lengths[wks_idx]);
+    uint32_t slot = hash_to_slot(hash);
+
     if (hdrtoken_hash_table[slot].wks) {
       printf("ERROR: hdrtoken_hash_table[%u] collision: '%s' replacing '%s'\n",
              slot, (const char*)wks, hdrtoken_hash_table[slot].wks);
       ++num_collisions;
     }
-    hdrtoken_hash_table[slot].wks = (const char *) wks;
+    hdrtoken_hash_table[slot].wks = (const char *)wks;
+    hdrtoken_hash_table[slot].hash = hash;
   }
+
   if (num_collisions > 0)
     abort();
 }
@@ -548,7 +558,7 @@ hdrtoken_hash_init()
 static inline unsigned int
 snap_up_to_multiple(unsigned int n, unsigned int unit)
 {
-  return (((n + (unit - 1)) / unit) * unit);
+  return ((n + (unit - 1)) / unit) * unit;
 }
 
 /*-------------------------------------------------------------------------
@@ -672,7 +682,7 @@ hdrtoken_tokenize_dfa(const char *string
   }
   //printf("hdrtoken_tokenize_dfa(%d,*s) - return %d\n",string_len,string,wks_idx);
 
-  return (wks_idx);
+  return wks_idx;
 }
 
 /*-------------------------------------------------------------------------
@@ -690,19 +700,23 @@ hdrtoken_tokenize(const char *string, in
     wks_idx = hdrtoken_wks_to_index(string);
     if (wks_string_out)
       *wks_string_out = string;
-    return (wks_idx);
+    return wks_idx;
   }
 
-  unsigned int slot = hdrtoken_hash((const unsigned char *) string, (unsigned int) string_len);
+  uint32_t hash = hdrtoken_hash((const unsigned char *) string, (unsigned int) string_len);
+  uint32_t slot = hash_to_slot(hash);
+
   bucket = &(hdrtoken_hash_table[slot]);
   if ((bucket->wks != NULL) &&
+      (bucket->hash == hash) &&
       (hdrtoken_wks_to_length(bucket->wks) == string_len)) {
     wks_idx = hdrtoken_wks_to_index(bucket->wks);
     if (wks_string_out)
       *wks_string_out = bucket->wks;
-    return (wks_idx);
+    return wks_idx;
   }
 
+  Debug("hdr_token", "Did not find a WKS for '%.*s'", string_len, string);
   return -1;
 }
 
@@ -714,7 +728,7 @@ hdrtoken_string_to_wks(const char *strin
 {
   const char *wks = NULL;
   hdrtoken_tokenize(string, (int) strlen(string), &wks);
-  return (wks);
+  return wks;
 }
 
 /*-------------------------------------------------------------------------
@@ -725,5 +739,5 @@ hdrtoken_string_to_wks(const char *strin
 {
   const char *wks = NULL;
   hdrtoken_tokenize(string, length, &wks);
-  return (wks);
+  return wks;
 }

Modified: trafficserver/traffic/branches/3.0.x/proxy/hdrs/MIME.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/branches/3.0.x/proxy/hdrs/MIME.cc?rev=1210237&r1=1210236&r2=1210237&view=diff
==============================================================================
--- trafficserver/traffic/branches/3.0.x/proxy/hdrs/MIME.cc (original)
+++ trafficserver/traffic/branches/3.0.x/proxy/hdrs/MIME.cc Sun Dec  4 21:44:52 2011
@@ -572,8 +572,8 @@ mime_hdr_sanity_check(MIMEHdrImpl * mh)
           const char *wks = hdrtoken_index_to_wks(field->m_wks_idx);
           int len = hdrtoken_index_to_length(field->m_wks_idx);
 
-          ink_release_assert(field->m_len_name == len);
-          ink_release_assert(strncasecmp(field->m_ptr_name, wks, field->m_len_name)
== 0);
+          if (field->m_len_name != len || strncasecmp(field->m_ptr_name, wks, field->m_len_name)
!= 0)
+            Warning("Encountered WKS hash collision on '%.*s'", field->m_len_name, field->m_ptr_name);
 
           uint64_t mask = mime_field_presence_mask(field->m_wks_idx);
           masksum |= mask;



Mime
View raw message