You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2014/10/09 18:17:54 UTC

[1/2] git commit: TS-3080: fix SSL session cache build

Repository: trafficserver
Updated Branches:
  refs/heads/master b4529fd61 -> 50520e7fe


TS-3080: fix SSL session cache build


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/067df58b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/067df58b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/067df58b

Branch: refs/heads/master
Commit: 067df58b5273ffb7773e161b0f3dae6e13c6e60e
Parents: b4529fd
Author: James Peach <jp...@apache.org>
Authored: Thu Oct 9 08:57:56 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Oct 9 09:17:29 2014 -0700

----------------------------------------------------------------------
 CHANGES                       |  7 +++++--
 iocore/net/SSLSessionCache.cc |  9 +++++----
 iocore/net/SSLSessionCache.h  | 10 ++++------
 3 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/067df58b/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 12739ac..1f6d81d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,11 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.2.0
-  
+
+  *) [TS-3120] Overlapping remap rank when using .include directives.
+   Author: Feifei Cai <ff...@yahoo-inc.com>
+
   *) [TS-3080] Optimized SSL session caching
- 
+
   *) [TS-3121] Prevent sending garbage HTTP/0.8 responses from SPDY
 
   *) [TS-3116] Add support for tracking the use of the ioBuffers

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/067df58b/iocore/net/SSLSessionCache.cc
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc
index c936ee7..5b36907 100644
--- a/iocore/net/SSLSessionCache.cc
+++ b/iocore/net/SSLSessionCache.cc
@@ -103,7 +103,7 @@ void SSLSessionBucket::insertSession(const SSLSessionID &id, const char *sni_nam
   size_t len = i2d_SSL_SESSION(sess, NULL); // make sure we're not going to need more than SSL_MAX_SESSION_SIZE bytes
   /* do not cache a session that's too big. */
   if (len > (size_t) SSL_MAX_SESSION_SIZE) {
-      Debug("ssl.session_cache", "Unable to save SSL session because size of %" PRId64 " exceeds the max of %d", len, SSL_MAX_SESSION_SIZE);
+      Debug("ssl.session_cache", "Unable to save SSL session because size of %zd exceeds the max of %d", len, SSL_MAX_SESSION_SIZE);
       return;
   }
 
@@ -194,7 +194,7 @@ void inline SSLSessionBucket::print(const char *ref_str) const {
   }
 
   fprintf(stderr, "-------------- BUCKET %p (%s) ----------------\n", this, ref_str);
-  fprintf(stderr, "Current Size: %d, Max Size: %" PRId64 "\n", queue.size, SSLConfigParams::session_cache_max_bucket_size);
+  fprintf(stderr, "Current Size: %d, Max Size: %zd\n", queue.size, SSLConfigParams::session_cache_max_bucket_size);
   fprintf(stderr, "Queue: \n");
 
   SSLSession *node = queue.head;
@@ -213,7 +213,7 @@ void inline SSLSessionBucket::removeOldestSession() {
     if (is_debug_tag_set("ssl.session_cache")) {
       char buf[old_head->session_id.len * 2 + 1];
       old_head->session_id.toString(buf, sizeof(buf));
-      Debug("ssl.session_cache", "Removing session '%s' from bucket %p because the bucket has size %d and max %" PRId64, buf, this, (queue.size + 1), SSLConfigParams::session_cache_max_bucket_size);
+      Debug("ssl.session_cache", "Removing session '%s' from bucket %p because the bucket has size %d and max %zd", buf, this, (queue.size + 1), SSLConfigParams::session_cache_max_bucket_size);
     }
     delete old_head;
   }
@@ -234,7 +234,8 @@ void SSLSessionBucket::removeSession(const SSLSessionID &id) {
 }
 
 /* Session Bucket */
-SSLSessionBucket::SSLSessionBucket() : root(NULL) {
+SSLSessionBucket::SSLSessionBucket()
+{
   Debug("ssl.session_cache", "Created new bucket %p with max size %ld", this, SSLConfigParams::session_cache_max_bucket_size);
 	ink_mutex_init(&mutex, "session_bucket");
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/067df58b/iocore/net/SSLSessionCache.h
----------------------------------------------------------------------
diff --git a/iocore/net/SSLSessionCache.h b/iocore/net/SSLSessionCache.h
index 283438a..ce5c8b1 100644
--- a/iocore/net/SSLSessionCache.h
+++ b/iocore/net/SSLSessionCache.h
@@ -19,8 +19,9 @@
   limitations under the License.
  */
 
-#ifndef SSL_SESSION_CACHE_
-#define SSL_SESSION_CACHE_
+#ifndef __SSLSESSIONCACHE_H__
+#define __SSLSESSIONCACHE_H__
+
 #include "Map.h"
 #include "List.h"
 #include "ink_mutex.h"
@@ -129,7 +130,6 @@ private:
 
   mutable ink_mutex mutex;
   CountQueue<SSLSession> queue;
-  SSLSession *root;
 };
 
 class SSLSessionCache {
@@ -144,6 +144,4 @@ public:
     SSLSessionBucket *session_bucket;
 };
 
-#endif
-
-
+#endif /* __SSLSESSIONCACHE_H__ */


[2/2] git commit: TS-3120: overlapping remap rank when using .include directives

Posted by jp...@apache.org.
TS-3120: overlapping remap rank when using .include directives

As described in the docs, we use line number for remap rule rank:

  Once these rules are executed we pick the lowest line number as
  the match (which replicates first-match-wins).

However, when we use .include directives to include some other remap
config files, there will be overlapping and conflict with the line
numbers in each other file.

*Examples*

  remap.config
    .include remap1.config
    .include remap2.config

  remap1.config
    map /foo/ https://www.yahoo.com

  remap2.config
    map /foo/bar1 https://www.yahoo.com
    map /foo/bar2 https://www.yahoo.com

When parsing remap1.config, first entry in remap1.config is inserted
with rank 0, second with rank 1. Then parsing remap2.config, the
single entry is inserted with rank 0 again. So the entry in
remap2.config is overlapped with first entry in remap1.config and
takes precedence with second entry. This would confuse customers.

I use count in UrlRewrite::_addToStore for rank. It is used to count
the number of each type of map rules(map, reverse_map,
map_with_referer...). When we insert a new url_mapping, it is stored
in a separate MappingsStore. So there would be no conflict with
each type's count.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/50520e7f
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/50520e7f
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/50520e7f

Branch: refs/heads/master
Commit: 50520e7fe5dea63ace1df4a03cdcbf0029bd820d
Parents: 067df58
Author: Feifei Cai <ff...@yahoo-inc.com>
Authored: Thu Oct 9 08:48:14 2014 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Oct 9 09:17:44 2014 -0700

----------------------------------------------------------------------
 doc/reference/configuration/remap.config.en.rst | 6 +++---
 proxy/http/remap/RemapConfig.cc                 | 2 +-
 proxy/http/remap/UrlMapping.h                   | 1 +
 proxy/http/remap/UrlRewrite.cc                  | 1 +
 4 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/50520e7f/doc/reference/configuration/remap.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/remap.config.en.rst b/doc/reference/configuration/remap.config.en.rst
index c32fc80..46b5b79 100644
--- a/doc/reference/configuration/remap.config.en.rst
+++ b/doc/reference/configuration/remap.config.en.rst
@@ -113,9 +113,9 @@ Traffic Server recognizes three space-delimited fields: ``type``,
 Precedence
 ==========
 
-Remap rules are not processed top-down, but based on an internal priority. Once
-these rules are executed we pick the lowest line number as the match (which
-replicates first-match-wins).
+Remap rules are not processed top-down, but based on an internal
+priority. Once these rules are executed we pick the first match
+based on configuration file parse order.
 
 1. ``map_with_recv_port`` and ```regex_map_with_recv_port```
 #. ``map`` and ``regex_map`` and ``reverse_map``

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/50520e7f/proxy/http/remap/RemapConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/RemapConfig.cc b/proxy/http/remap/RemapConfig.cc
index 398039f..70987e1 100644
--- a/proxy/http/remap/RemapConfig.cc
+++ b/proxy/http/remap/RemapConfig.cc
@@ -984,7 +984,7 @@ remap_parse_config_bti(const char * path, BUILD_TABLE_INFO * bti)
       goto MAP_ERROR;
     }
 
-    new_mapping = new url_mapping(cln);  // use line # for rank for now
+    new_mapping = new url_mapping();
 
     // apply filter rules if we have to
     if ((errStr = process_filter_opt(new_mapping, bti, errStrBuf, sizeof(errStrBuf))) != NULL) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/50520e7f/proxy/http/remap/UrlMapping.h
----------------------------------------------------------------------
diff --git a/proxy/http/remap/UrlMapping.h b/proxy/http/remap/UrlMapping.h
index cd4b1e3..ad9c1de 100644
--- a/proxy/http/remap/UrlMapping.h
+++ b/proxy/http/remap/UrlMapping.h
@@ -117,6 +117,7 @@ public:
   LINK(url_mapping, link); // For use with the main Queue linked list holding all the mapping
 
   int getRank() const { return _rank; };
+  void setRank(int rank) { _rank = rank; };
 
 private:
   remap_plugin_info* _plugin_list[MAX_REMAP_PLUGIN_CHAIN];

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/50520e7f/proxy/http/remap/UrlRewrite.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index a9897e9..a3f547c 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -582,6 +582,7 @@ UrlRewrite::_addToStore(MappingsStore &store, url_mapping *new_mapping, RegexMap
     store.regex_list.enqueue(reg_map);
     retval = true;
   } else {
+    new_mapping->setRank(count); // Use the mapping rules number count for rank
     retval = TableInsert(store.hash_lookup, new_mapping, src_host);
   }
   if (retval) {