Updated Branches: refs/heads/5.0.x be93cfbee -> 812b668de
TS-1919 Eliminate CacheLookupHttpConfig This breaks compatibility with the cache clustering, so all nodes in a cluster would have to be upgraded at the same time. This eliminates an ugly passing of certain configurations through the cluster channels into the cache core. In addition, I think this can open up the possibility to make some cache related configurations overridable. That should be done as a different commit though. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/06278946 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/06278946 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/06278946 Branch: refs/heads/5.0.x Commit: 062789462cf34355627d35c8a2899d822e38950a Parents: be93cfb Author: Leif Hedstrom <[email protected]> Authored: Sat Jun 1 16:27:31 2013 -0600 Committer: Leif Hedstrom <[email protected]> Committed: Wed Aug 21 11:03:35 2013 -0600 ---------------------------------------------------------------------- iocore/cache/Cache.cc | 8 +- iocore/cache/CacheRead.cc | 10 +-- iocore/cache/I_Cache.h | 15 ++-- iocore/cache/P_CacheInternal.h | 46 +++++------ iocore/cache/P_CacheTest.h | 1 - iocore/cluster/ClusterCache.cc | 26 +++--- iocore/cluster/P_ClusterCacheInternal.h | 15 ++-- iocore/cluster/P_ClusterInline.h | 15 +--- proxy/ICP.cc | 3 +- proxy/Prefetch.cc | 19 ++--- proxy/Prefetch.h | 2 +- proxy/http/HttpCacheSM.cc | 8 +- proxy/http/HttpCacheSM.h | 9 +-- proxy/http/HttpSM.cc | 15 +--- proxy/http/HttpTransact.h | 2 - proxy/http/HttpTransactCache.cc | 113 +++------------------------ proxy/http/HttpTransactCache.h | 61 ++------------- 17 files changed, 87 insertions(+), 281 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cache/Cache.cc ---------------------------------------------------------------------- diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc index 66f2b70..fdf67b7 100644 --- a/iocore/cache/Cache.cc +++ b/iocore/cache/Cache.cc @@ -3189,15 +3189,15 @@ ink_cache_init(ModuleVersion v) //---------------------------------------------------------------------------- Action * CacheProcessor::open_read(Continuation *cont, URL *url, bool cluster_cache_local, CacheHTTPHdr *request, - CacheLookupHttpConfig *params, time_t pin_in_cache, CacheFragType type) + void *context, time_t pin_in_cache, CacheFragType type) { #ifdef CLUSTER_CACHE if (cache_clustering_enabled > 0 && !cluster_cache_local) { - return open_read_internal(CACHE_OPEN_READ_LONG, cont, (MIOBuffer *) 0, - url, request, params, (CacheKey *) 0, pin_in_cache, type, (char *) 0, 0); + return open_read_internal(CACHE_OPEN_READ_LONG, cont, (MIOBuffer *) 0, url, request, context, + (CacheKey *) 0, pin_in_cache, type, (char *) 0, 0); } #endif - return caches[type]->open_read(cont, url, request, params, type); + return caches[type]->open_read(cont, url, request, context, type); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cache/CacheRead.cc ---------------------------------------------------------------------- diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc index 3c97305..6b8e897 100644 --- a/iocore/cache/CacheRead.cc +++ b/iocore/cache/CacheRead.cc @@ -90,7 +90,7 @@ Lcallreturn: #ifdef HTTP_CACHE Action * Cache::open_read(Continuation * cont, CacheKey * key, CacheHTTPHdr * request, - CacheLookupHttpConfig * params, CacheFragType type, char *hostname, int host_len) + void * context, CacheFragType type, char *hostname, int host_len) { if (!CACHE_READY(type)) { @@ -116,7 +116,7 @@ Cache::open_read(Continuation * cont, CacheKey * key, CacheHTTPHdr * request, CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); c->request.copy_shallow(request); c->frag_type = CACHE_FRAG_TYPE_HTTP; - c->params = params; + c->context = context; c->od = od; } if (!lock) { @@ -243,7 +243,7 @@ CacheVC::openReadChooseWriter(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSE } #ifdef FIXME_NONMODULAR if (cache_config_select_alternate) { - alternate_index = HttpTransactCache::SelectFromAlternates(&vector, &request, params); + alternate_index = HttpTransactCache::SelectFromAlternates(&vector, &request, static_cast<HttpConfigParams*>(context)); if (alternate_index < 0) return -ECACHE_ALT_MISS; } else @@ -972,7 +972,7 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */ if (od->move_resident_alt) dir_insert(&od->single_doc_key, vol, &od->single_doc_dir); #ifdef FIXME_NONMODULAR - int alt_ndx = HttpTransactCache::SelectFromAlternates(write_vector, &request, params); + int alt_ndx = HttpTransactCache::SelectFromAlternates(write_vector, &request, static_cast<HttpConfigParams*>(context)); #else int alt_ndx = 0; #endif @@ -1082,7 +1082,7 @@ CacheVC::openReadStartHead(int event, Event * e) } if (cache_config_select_alternate) { #ifdef FIXME_NONMODULAR - alternate_index = HttpTransactCache::SelectFromAlternates(&vector, &request, params); + alternate_index = HttpTransactCache::SelectFromAlternates(&vector, &request, static_cast<HttpConfigParams*>(context)); #else alternate_index = 0; #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cache/I_Cache.h ---------------------------------------------------------------------- diff --git a/iocore/cache/I_Cache.h b/iocore/cache/I_Cache.h index 00e4791..02113f8 100644 --- a/iocore/cache/I_Cache.h +++ b/iocore/cache/I_Cache.h @@ -53,7 +53,6 @@ struct CacheVC; #ifdef HTTP_CACHE -class CacheLookupHttpConfig; class URL; class HTTPHdr; class HTTPInfo; @@ -107,14 +106,10 @@ struct CacheProcessor:public Processor #ifdef HTTP_CACHE Action *lookup(Continuation *cont, URL *url, bool cluster_cache_local, bool local_only = false, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); - inkcoreapi Action *open_read(Continuation *cont, URL *url, - bool cluster_cache_local, - CacheHTTPHdr *request, - CacheLookupHttpConfig *params, - time_t pin_in_cache = (time_t) 0, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); - Action *open_read_buffer(Continuation *cont, MIOBuffer *buf, URL *url, - CacheHTTPHdr *request, - CacheLookupHttpConfig *params, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); + inkcoreapi Action *open_read(Continuation *cont, URL *url, bool cluster_cache_local, CacheHTTPHdr *request, + void *context, time_t pin_in_cache = (time_t) 0, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); + Action *open_read_buffer(Continuation *cont, MIOBuffer *buf, URL *url, CacheHTTPHdr *request, + void *context, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); Action *open_write(Continuation *cont, int expected_size, URL *url, bool cluster_cache_local, CacheHTTPHdr *request, CacheHTTPInfo *old_info, time_t pin_in_cache = (time_t) 0, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); @@ -124,7 +119,7 @@ struct CacheProcessor:public Processor Action *remove(Continuation *cont, URL *url, bool cluster_cache_local, CacheFragType frag_type = CACHE_FRAG_TYPE_HTTP); Action *open_read_internal(int, Continuation *, MIOBuffer *, CacheURL *, - CacheHTTPHdr *, CacheLookupHttpConfig *, + CacheHTTPHdr *, void *, CacheKey *, time_t, CacheFragType type, char *hostname, int host_len); #endif Action *link(Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local, http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cache/P_CacheInternal.h ---------------------------------------------------------------------- diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h index 4f33fdc..eecd646 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -431,7 +431,7 @@ struct CacheVC: public CacheVConnection CacheHTTPInfo *info; CacheHTTPInfoVector *write_vector; #ifdef HTTP_CACHE - CacheLookupHttpConfig *params; + void *context; #endif int header_len; // for communicating with agg_copy int frag_len; // for communicating with agg_copy @@ -1044,9 +1044,9 @@ struct Cache Action *lookup(Continuation *cont, URL *url, CacheFragType type); inkcoreapi Action *open_read(Continuation *cont, CacheKey *key, CacheHTTPHdr *request, - CacheLookupHttpConfig *params, CacheFragType type, char *hostname, int host_len); + void *context, CacheFragType type, char *hostname, int host_len); Action *open_read(Continuation *cont, URL *url, CacheHTTPHdr *request, - CacheLookupHttpConfig *params, CacheFragType type); + void *context, CacheFragType type); Action *open_write(Continuation *cont, CacheKey *key, CacheHTTPInfo *old_info, time_t pin_in_cache = (time_t) 0, CacheKey *key1 = NULL, @@ -1078,14 +1078,13 @@ inkcoreapi extern Cache *caches[NUM_CACHE_FRAG_TYPES]; #ifdef HTTP_CACHE TS_INLINE Action * -Cache::open_read(Continuation *cont, CacheURL *url, CacheHTTPHdr *request, - CacheLookupHttpConfig *params, CacheFragType type) +Cache::open_read(Continuation *cont, CacheURL *url, CacheHTTPHdr *request, void *context, CacheFragType type) { INK_MD5 md5; int len; url->MD5_get(&md5); const char *hostname = url->host_get(&len); - return open_read(cont, &md5, request, params, type, (char *) hostname, len); + return open_read(cont, &md5, request, context, type, (char *) hostname, len); } TS_INLINE void @@ -1188,9 +1187,8 @@ CacheProcessor::open_read(Continuation *cont, CacheKey *key, bool cluster_cache_ { #ifdef CLUSTER_CACHE if (cache_clustering_enabled > 0 && !cluster_cache_local) { - return open_read_internal(CACHE_OPEN_READ, cont, (MIOBuffer *) 0, - (CacheURL *) 0, (CacheHTTPHdr *) 0, - (CacheLookupHttpConfig *) 0, key, 0, frag_type, hostname, host_len); + return open_read_internal(CACHE_OPEN_READ, cont, (MIOBuffer *) 0, (CacheURL *) 0, (CacheHTTPHdr *) 0, + (void *) 0, key, 0, frag_type, hostname, host_len); } #endif return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len); @@ -1202,9 +1200,8 @@ CacheProcessor::open_read_buffer(Continuation *cont, MIOBuffer *buf ATS_UNUSED, { #ifdef CLUSTER_CACHE if (cache_clustering_enabled > 0) { - return open_read_internal(CACHE_OPEN_READ_BUFFER, cont, buf, - (CacheURL *) 0, (CacheHTTPHdr *) 0, - (CacheLookupHttpConfig *) 0, key, 0, frag_type, hostname, host_len); + return open_read_internal(CACHE_OPEN_READ_BUFFER, cont, buf, (CacheURL *) 0, (CacheHTTPHdr *) 0, + (void*) 0, key, 0, frag_type, hostname, host_len); } #endif return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len); @@ -1285,17 +1282,17 @@ CacheProcessor::lookup(Continuation *cont, URL *url, bool cluster_cache_local, b } TS_INLINE Action * -CacheProcessor::open_read_buffer(Continuation *cont, MIOBuffer *buf, - URL *url, CacheHTTPHdr *request, CacheLookupHttpConfig *params, CacheFragType type) +CacheProcessor::open_read_buffer(Continuation *cont, MIOBuffer *buf, URL *url, CacheHTTPHdr *request, + void *context, CacheFragType type) { (void) buf; #ifdef CLUSTER_CACHE if (cache_clustering_enabled > 0) { - return open_read_internal(CACHE_OPEN_READ_BUFFER_LONG, cont, buf, url, - request, params, (CacheKey *) 0, 0, type, (char *) 0, 0); + return open_read_internal(CACHE_OPEN_READ_BUFFER_LONG, cont, buf, url, request, context, (CacheKey *) 0, + 0, type, (char *) 0, 0); } #endif - return caches[type]->open_read(cont, url, request, params, type); + return caches[type]->open_read(cont, url, request, context, type); } TS_INLINE Action * @@ -1317,13 +1314,9 @@ CacheProcessor::open_write_buffer(Continuation * cont, MIOBuffer * buf, URL * ur #ifdef CLUSTER_CACHE TS_INLINE Action * -CacheProcessor::open_read_internal(int opcode, - Continuation *cont, MIOBuffer *buf, - CacheURL *url, - CacheHTTPHdr *request, - CacheLookupHttpConfig *params, - CacheKey *key, - time_t pin_in_cache, CacheFragType frag_type, char *hostname, int host_len) +CacheProcessor::open_read_internal(int opcode, Continuation *cont, MIOBuffer *buf, CacheURL *url, CacheHTTPHdr *request, + void *context, CacheKey *key, time_t pin_in_cache, CacheFragType frag_type, char *hostname, + int host_len) { INK_MD5 url_md5; if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) { @@ -1334,12 +1327,11 @@ CacheProcessor::open_read_internal(int opcode, ClusterMachine *m = cluster_machine_at_depth(cache_hash(url_md5)); if (m) { - return Cluster_read(m, opcode, cont, buf, url, - request, params, key, pin_in_cache, frag_type, hostname, host_len); + return Cluster_read(m, opcode, cont, buf, url, request, key, pin_in_cache, frag_type, hostname, host_len); } else { if ((opcode == CACHE_OPEN_READ_LONG) || (opcode == CACHE_OPEN_READ_BUFFER_LONG)) { - return caches[frag_type]->open_read(cont, &url_md5, request, params, frag_type, hostname, host_len); + return caches[frag_type]->open_read(cont, &url_md5, request, context, frag_type, hostname, host_len); } else { return caches[frag_type]->open_read(cont, key, frag_type, hostname, host_len); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cache/P_CacheTest.h ---------------------------------------------------------------------- diff --git a/iocore/cache/P_CacheTest.h b/iocore/cache/P_CacheTest.h index 8ef83ca..2959ea3 100644 --- a/iocore/cache/P_CacheTest.h +++ b/iocore/cache/P_CacheTest.h @@ -76,7 +76,6 @@ struct CacheTestSM : public RegressionSM { MIOBuffer *buffer; IOBufferReader *buffer_reader; #ifdef HTTP_CACHE - CacheLookupHttpConfig params; CacheHTTPInfo info; char urlstr[1024]; #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cluster/ClusterCache.cc ---------------------------------------------------------------------- diff --git a/iocore/cluster/ClusterCache.cc b/iocore/cluster/ClusterCache.cc index 8d4b6e5..fc80ef5 100644 --- a/iocore/cluster/ClusterCache.cc +++ b/iocore/cluster/ClusterCache.cc @@ -1212,14 +1212,6 @@ cache_op_ClusterFunction(ClusterHandler * ch, void *data, int len) moi_len -= res; p += res; ink_assert(moi_len > 0); - // Unmarshal CacheLookupHttpConfig - c->ic_params = new(CacheLookupHttpConfigAllocator.alloc()) - CacheLookupHttpConfig(); - res = c->ic_params->unmarshal(&c->ic_arena, (const char *) p, moi_len); - ink_assert(res > 0); - - moi_len -= res; - p += res; CacheKey key(msg->url_md5); @@ -1239,9 +1231,10 @@ cache_op_ClusterFunction(ClusterHandler * ch, void *data, int len) memcpy(c->ic_hostname->data(), hostname, host_len); } + c->http_config_params = HttpConfig::acquire(); Cache *call_cache = caches[c->frag_type]; Action *a = call_cache->open_read(c, &key, &c->ic_request, - c->ic_params, + c->http_config_params, c->frag_type, hostname, host_len); // Get rid of purify warnings since 'c' can be freed by open_read. if (a != ACTION_RESULT_DONE) { @@ -1880,22 +1873,21 @@ struct retryDisposeOfDataBuffer:public Continuation { CacheContinuation *c; - int handleRetryEvent(int event, Event * e) - { + int handleRetryEvent(int event, Event * e) { if (CacheContinuation::handleDisposeEvent(event, c) == EVENT_DONE) { delete this; - return EVENT_DONE; - } else - { + return EVENT_DONE; + } else { e->schedule_in(HRTIME_MSECONDS(10)); return EVENT_CONT; } } + retryDisposeOfDataBuffer(CacheContinuation * cont) -: Continuation(new_ProxyMutex()), c(cont) { - SET_HANDLER((rtryDisOfDBufHandler) - & retryDisposeOfDataBuffer::handleRetryEvent); + : Continuation(new_ProxyMutex()), c(cont) { + SET_HANDLER((rtryDisOfDBufHandler) &retryDisposeOfDataBuffer::handleRetryEvent); } + }; ////////////////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cluster/P_ClusterCacheInternal.h ---------------------------------------------------------------------- diff --git a/iocore/cluster/P_ClusterCacheInternal.h b/iocore/cluster/P_ClusterCacheInternal.h index 8b62d44..907d6f5 100644 --- a/iocore/cluster/P_ClusterCacheInternal.h +++ b/iocore/cluster/P_ClusterCacheInternal.h @@ -30,6 +30,7 @@ #define __P_CLUSTERCACHEINTERNAL_H__ #include "P_ClusterCache.h" #include "I_OneWayTunnel.h" +#include "HttpConfig.h" // // Compilation Options @@ -164,10 +165,10 @@ struct CacheContinuation:public Continuation Arena ic_arena; CacheHTTPHdr ic_request; CacheHTTPHdr ic_response; - CacheLookupHttpConfig *ic_params; + HttpConfigParams *http_config_params; CacheHTTPInfo ic_old_info; CacheHTTPInfo ic_new_info; - Ptr<IOBufferData> ic_hostname; + Ptr<IOBufferData> ic_hostname; int ic_hostname_len; // debugging @@ -246,11 +247,11 @@ struct CacheContinuation:public Continuation if (cache_vc_info.valid()) { cache_vc_info.destroy(); } - // Deallocate unmarshaled data - if (ic_params) { - delete ic_params; - ic_params = 0; + if (http_config_params) { + HttpConfig::release(http_config_params); + http_config_params = 0; } + if (ic_request.valid()) { ic_request.clear(); } @@ -311,7 +312,7 @@ CacheContinuation(): lookup_open_write_vc_event(0), ic_arena(), ic_request(), - ic_response(), ic_params(0), ic_old_info(), ic_new_info(), ic_hostname_len(0), cache_op_ClusterFunction(0) { + ic_response(), http_config_params(0), ic_old_info(), ic_new_info(), ic_hostname_len(0), cache_op_ClusterFunction(0) { token.clear(); SET_HANDLER((CacheContHandler) & CacheContinuation::remoteOpEvent); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/iocore/cluster/P_ClusterInline.h ---------------------------------------------------------------------- diff --git a/iocore/cluster/P_ClusterInline.h b/iocore/cluster/P_ClusterInline.h index c653956..75fa571 100644 --- a/iocore/cluster/P_ClusterInline.h +++ b/iocore/cluster/P_ClusterInline.h @@ -59,13 +59,10 @@ Cluster_lookup(Continuation * cont, CacheKey * key, CacheFragType frag_type, cha } inline Action * -Cluster_read(ClusterMachine * owner_machine, int opcode, - Continuation * cont, MIOBuffer * buf, - CacheURL * url, CacheHTTPHdr * request, - CacheLookupHttpConfig * params, CacheKey * key, - time_t pin_in_cache, CacheFragType frag_type, char *hostname, int host_len) +Cluster_read(ClusterMachine * owner_machine, int opcode, Continuation * cont, MIOBuffer * buf, CacheURL * url, + CacheHTTPHdr * request, CacheKey * key, time_t pin_in_cache, CacheFragType frag_type, char *hostname, + int host_len) { - (void) params; if (clusterProcessor.disable_remote_cluster_ops(owner_machine)) { Action a; a = cont; @@ -93,7 +90,6 @@ Cluster_read(ClusterMachine * owner_machine, int opcode, url_hostname = url->host_get(&url_hlen); len += request->m_heap->marshal_length(); - len += params->marshal_length(); len += url_hlen; if ((flen + len) > DEFAULT_MAX_BUFFER_SIZE) // Bound marshalled data @@ -110,10 +106,7 @@ Cluster_read(ClusterMachine * owner_machine, int opcode, } data += res; cur_len -= res; - if ((res = params->marshal(data, cur_len)) < 0) - goto err_exit; - data += res; - cur_len -= res; + memcpy(data, url_hostname, url_hlen); CacheOpArgs_General readArgs; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/ICP.cc ---------------------------------------------------------------------- diff --git a/proxy/ICP.cc b/proxy/ICP.cc index 4ed8e29..8498d93 100644 --- a/proxy/ICP.cc +++ b/proxy/ICP.cc @@ -43,7 +43,6 @@ #include "BaseManager.h" #include "HdrUtils.h" -extern CacheLookupHttpConfig global_cache_lookup_config; HTTPHdr gclient_request; //**************************************************************************** @@ -481,7 +480,7 @@ ICPPeerReadCont::ICPPeerQueryCont(int /* event ATS_UNUSED */, Event * /* e ATS_U // cache clustering is not used with stale lookup. ////////////////////////////////////////////////////////////// a = cacheProcessor.open_read(this, &_state->_cachelookupURL, false, - &gclient_request, &global_cache_lookup_config, (time_t) 0); + &gclient_request, NULL, (time_t) 0); } else { a = cacheProcessor.lookup(this, &_state->_cachelookupURL, false, _state->_cache_lookup_local); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/Prefetch.cc ---------------------------------------------------------------------- diff --git a/proxy/Prefetch.cc b/proxy/Prefetch.cc index 41a6419..b972a24 100644 --- a/proxy/Prefetch.cc +++ b/proxy/Prefetch.cc @@ -1132,6 +1132,11 @@ PrefetchBlaster::free() delete request; } + if (http_config_params) { + HttpConfig::release(http_config_params); + http_config_params = 0; + } + mutex.clear(); prefetchBlasterAllocator.free(this); } @@ -1485,7 +1490,7 @@ PrefetchBlaster::handleEvent(int event, void *data) //if (cache_lookup_necessary) do: initCacheLookupConfig(); - cacheProcessor.open_read(this, request->url_get(), false, request, &cache_lookup_config, 0); + cacheProcessor.open_read(this, request->url_get(), false, request, http_config_params, 0); break; } @@ -1863,17 +1868,7 @@ PrefetchBlaster::invokeBlaster() void PrefetchBlaster::initCacheLookupConfig() { - //The look up parameters are intialized in the same as it is done - //in HttpSM::init(). Any changes there should come in here. - HttpConfigParams *http_config_params = HttpConfig::acquire(); - cache_lookup_config.cache_global_user_agent_header = http_config_params->global_user_agent_header ? true : false; - cache_lookup_config.cache_enable_default_vary_headers = - http_config_params->cache_enable_default_vary_headers ? true : false; - cache_lookup_config.cache_vary_default_text = http_config_params->cache_vary_default_text; - cache_lookup_config.cache_vary_default_images = http_config_params->cache_vary_default_images; - cache_lookup_config.cache_vary_default_other = http_config_params->cache_vary_default_other; - - HttpConfig::release(http_config_params); + this->http_config_params = HttpConfig::acquire(); } static int http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/Prefetch.h ---------------------------------------------------------------------- diff --git a/proxy/Prefetch.h b/proxy/Prefetch.h index 34289fa..ec8a9ec 100644 --- a/proxy/Prefetch.h +++ b/proxy/Prefetch.h @@ -328,7 +328,7 @@ public: PrefetchBlastData data_blast; - CacheLookupHttpConfig cache_lookup_config; + HttpConfigParams *http_config_params; //udp related: uint32_t n_pkts_sent; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpCacheSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpCacheSM.cc b/proxy/http/HttpCacheSM.cc index 7f82dd5..f5f05e7 100644 --- a/proxy/http/HttpCacheSM.cc +++ b/proxy/http/HttpCacheSM.cc @@ -212,8 +212,8 @@ HttpCacheSM::do_cache_open_read() } //Initialising read-while-write-inprogress flag this->readwhilewrite_inprogress = false; - Action *action_handle = cacheProcessor.open_read(this, this->lookup_url, master_sm->t_state.cache_control.cluster_cache_local, this->read_request_hdr, this->read_config, - this->read_pin_in_cache); + Action *action_handle = cacheProcessor.open_read(this, this->lookup_url, master_sm->t_state.cache_control.cluster_cache_local, + this->read_request_hdr, this->read_config, this->read_pin_in_cache); if (action_handle != ACTION_RESULT_DONE) { pending_action = action_handle; @@ -231,13 +231,13 @@ HttpCacheSM::do_cache_open_read() } Action * -HttpCacheSM::open_read(URL * url, HTTPHdr * hdr, CacheLookupHttpConfig * params, time_t pin_in_cache) +HttpCacheSM::open_read(URL * url, HTTPHdr * hdr, HttpConfigParams *http_config_params, time_t pin_in_cache) { Action *act_return; lookup_url = url; read_request_hdr = hdr; - read_config = params; + read_config = http_config_params; read_pin_in_cache = pin_in_cache; ink_assert(pending_action == NULL); SET_HANDLER(&HttpCacheSM::state_cache_open_read); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpCacheSM.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpCacheSM.h b/proxy/http/HttpCacheSM.h index a6b40a9..e2af016 100644 --- a/proxy/http/HttpCacheSM.h +++ b/proxy/http/HttpCacheSM.h @@ -42,7 +42,6 @@ class HttpSM; class HttpCacheSM; -class CacheLookupHttpConfig; struct HttpCacheAction:public Action { @@ -67,10 +66,10 @@ public: captive_action.init(this); } - Action *open_read(URL * url, HTTPHdr * hdr, CacheLookupHttpConfig * params, time_t pin_in_cache); + Action *open_read(URL * url, HTTPHdr * hdr, HttpConfigParams * http_config_params, time_t pin_in_cache); - Action *open_write(URL * url, - HTTPHdr * request, CacheHTTPInfo * old_info, time_t pin_in_cache, bool retry, bool allow_multiple); + Action *open_write(URL * url, HTTPHdr * request, CacheHTTPInfo * old_info, time_t pin_in_cache, bool retry, + bool allow_multiple); CacheVConnection *cache_read_vc; CacheVConnection *cache_write_vc; @@ -158,7 +157,7 @@ private: // Open read parameters int open_read_tries; HTTPHdr *read_request_hdr; - CacheLookupHttpConfig *read_config; + HttpConfigParams *read_config; time_t read_pin_in_cache; // Open write parameters http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index ba460da..13526f4 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -405,19 +405,6 @@ HttpSM::init() // entire struct if nothing is going to change it. t_state.txn_conf = &t_state.http_config_param->oride; - // update the cache info config structure so that - // selection from alternates happens correctly. - t_state.cache_info.config.cache_global_user_agent_header = t_state.http_config_param->global_user_agent_header ? true : false; - t_state.cache_info.config.ignore_accept_mismatch = t_state.http_config_param->ignore_accept_mismatch ? true : false; - t_state.cache_info.config.ignore_accept_language_mismatch = t_state.http_config_param->ignore_accept_language_mismatch ? true : false; - t_state.cache_info.config.ignore_accept_encoding_mismatch = t_state.http_config_param->ignore_accept_encoding_mismatch ? true : false; - t_state.cache_info.config.ignore_accept_charset_mismatch = t_state.http_config_param->ignore_accept_charset_mismatch ? true : false; - t_state.cache_info.config.cache_enable_default_vary_headers = t_state.http_config_param->cache_enable_default_vary_headers ? true : false; - - t_state.cache_info.config.cache_vary_default_text = t_state.http_config_param->cache_vary_default_text; - t_state.cache_info.config.cache_vary_default_images = t_state.http_config_param->cache_vary_default_images; - t_state.cache_info.config.cache_vary_default_other = t_state.http_config_param->cache_vary_default_other; - t_state.init(); t_state.srv_lookup = hostdb_srv_enabled; @@ -4268,7 +4255,7 @@ HttpSM::do_cache_lookup_and_read() DebugSM("http_seq", "[HttpSM::do_cache_lookup_and_read] [%" PRId64 "] Issuing cache lookup for URL %s", sm_id, c_url->string_get(&t_state.arena)); Action *cache_action_handle = cache_sm.open_read(c_url, &t_state.hdr_info.client_request, - &(t_state.cache_info.config), + t_state.http_config_param, (time_t) ((t_state.cache_control.pin_in_cache_for < 0) ? 0 : t_state.cache_control.pin_in_cache_for)); // http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpTransact.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h index dab46d2..405f157 100644 --- a/proxy/http/HttpTransact.h +++ b/proxy/http/HttpTransact.h @@ -636,7 +636,6 @@ public: HTTPInfo *second_object_read; HTTPInfo object_store; HTTPInfo transform_store; - CacheLookupHttpConfig config; CacheDirectives directives; int open_read_retries; int open_write_retries; @@ -656,7 +655,6 @@ public: second_object_read(NULL), object_store(), transform_store(), - config(), directives(), open_read_retries(0), open_write_retries(0), http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpTransactCache.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc index b89dfa0..ada10bc 100644 --- a/proxy/http/HttpTransactCache.cc +++ b/proxy/http/HttpTransactCache.cc @@ -32,10 +32,6 @@ #include "Error.h" #include "InkErrno.h" -ClassAllocator<CacheLookupHttpConfig> CacheLookupHttpConfigAllocator("CacheLookupHttpConfigAllocator"); - -CacheLookupHttpConfig global_cache_lookup_config; - /** Find the pointer and length of an etag, after stripping off any leading "W/" prefix, and surrounding double quotes. @@ -165,21 +161,22 @@ is_empty(char *s) */ int -HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, - HTTPHdr * client_request, CacheLookupHttpConfig * http_config_params) +HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, HTTPHdr * client_request, + HttpConfigParams * http_config_params) { time_t current_age, best_age = NUM_SECONDS_IN_ONE_YEAR; time_t t_now = 0; int best_index = -1; float best_Q = -1.0; float unacceptable_Q = 0.0; - int alt_count = cache_vector->count(); + + // TODO: for ICP we also want to exit here with a return 0, it's what the + // old code implied. if (alt_count == 0) { return -1; } - Debug("http_match", "[SelectFromAlternates] # alternates = %d", alt_count); Debug("http_seq", "[SelectFromAlternates] %d alternates for this cached doc", alt_count); if (diags->on("http_alts")) { @@ -187,9 +184,6 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, fprintf(stderr, "[alts] There are %d alternates for this request header.\n", alt_count); RELEASE_PRINT_LOCK() } - // used by ICP to bypass this function - if (http_config_params == &global_cache_lookup_config) - return 0; if (!client_request->valid()) { return 0; @@ -296,11 +290,8 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector * cache_vector, */ float -HttpTransactCache::calculate_quality_of_match(CacheLookupHttpConfig * http_config_param, // in - HTTPHdr * client_request, // in - HTTPHdr * obj_client_request, // in - HTTPHdr * obj_origin_server_response // in - ) +HttpTransactCache::calculate_quality_of_match(HttpConfigParams * http_config_param, HTTPHdr * client_request, + HTTPHdr * obj_client_request, HTTPHdr * obj_origin_server_response) { float q[4], Q; MIMEField *accept_field; @@ -1141,8 +1132,7 @@ language_wildcard: */ Variability_t -HttpTransactCache::CalcVariability(CacheLookupHttpConfig * http_config_params, - HTTPHdr * client_request, +HttpTransactCache::CalcVariability(HttpConfigParams * http_config_params, HTTPHdr * client_request, HTTPHdr * obj_client_request, HTTPHdr * obj_origin_server_response) { ink_assert(http_config_params != NULL); @@ -1229,7 +1219,7 @@ HttpTransactCache::CalcVariability(CacheLookupHttpConfig * http_config_params, // we should ignore Vary: User-Agent even if 'proxy.config.cache.vary_on_user_agent' // // is 1. Actually the 'proxy.config.cache.vary_on_user_agent' is useless in such case // /////////////////////////////////////////////////////////////////////////////////////// - if (http_config_params->cache_global_user_agent_header && + if (http_config_params->global_user_agent_header && !strcasecmp((char *) field->str, "User-Agent")) continue; @@ -1473,88 +1463,3 @@ L1: return response->status_get(); } - - -/*--------------------------------------------------- - * class CacheLookupHttpConfig - *---------------------------------------------------*/ -int -CacheLookupHttpConfig::marshal_length() -{ - int len = (int) sizeof(int32_t); - len += (cache_vary_default_text ? strlen(cache_vary_default_text) + 1 : 1); - len += (cache_vary_default_images ? strlen(cache_vary_default_images) + 1 : 1); - len += (cache_vary_default_other ? strlen(cache_vary_default_other) + 1 : 1); - return len; -} - -int -CacheLookupHttpConfig::marshal(char *buf, int length) -{ - int32_t i32_tmp; - char *p = buf; - int len; - - if ((length -= sizeof(int32_t)) < 0) - return -1; - - i32_tmp = (int32_t) cache_enable_default_vary_headers; - memcpy(p, &i32_tmp, sizeof(int32_t)); - p += sizeof(int32_t); - - len = (cache_vary_default_text ? strlen(cache_vary_default_text) + 1 : 1); - if ((length -= len) < 0) - return -1; - ink_strlcpy(p, (cache_vary_default_text ? cache_vary_default_text : ""), length); - p += len; - - len = (cache_vary_default_images ? strlen(cache_vary_default_images) + 1 : 1); - if ((length -= len) < 0) - return -1; - ink_strlcpy(p, (cache_vary_default_images ? cache_vary_default_images : ""), length); - p += len; - - len = (cache_vary_default_other ? strlen(cache_vary_default_other) + 1 : 1); - if ((length -= len) < 0) - return -1; - ink_strlcpy(p, (cache_vary_default_other ? cache_vary_default_other : ""), length); - p += len; - - return (p - buf); -} - -int -CacheLookupHttpConfig::unmarshal(Arena * arena, const char *buf, int buflen) -{ - const char *p = buf; - int length = buflen; - int len; - int32_t i32_tmp; - - if ((length -= sizeof(int32_t)) < 0) - return -1; - - memcpy(&i32_tmp, p, sizeof(int32_t)); - cache_enable_default_vary_headers = (bool) i32_tmp; - p += sizeof(int32_t); - - len = strlen(p) + 1; - if ((length -= len) < 0) - return -1; - cache_vary_default_text = arena->str_store(((len == 2) ? "" : p), len - 1); - p += len; - - len = strlen(p) + 1; - if ((length -= len) < 0) - return -1; - cache_vary_default_images = arena->str_store(((len == 2) ? "" : p), len - 1); - p += len; - - len = strlen(p) + 1; - if ((length -= len) < 0) - return -1; - cache_vary_default_other = arena->str_store(((len == 2) ? "" : p), len - 1); - p += len; - - return (p - buf); -} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/06278946/proxy/http/HttpTransactCache.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransactCache.h b/proxy/http/HttpTransactCache.h index 0165c27..90c5614 100644 --- a/proxy/http/HttpTransactCache.h +++ b/proxy/http/HttpTransactCache.h @@ -35,54 +35,6 @@ struct CacheHTTPInfoVector; -class CacheLookupHttpConfig -{ -public: - bool cache_global_user_agent_header; // 'global' user agent flag (don't need to marshal/unmarshal) - bool cache_enable_default_vary_headers; - bool ignore_accept_mismatch; - bool ignore_accept_language_mismatch; - bool ignore_accept_encoding_mismatch; - bool ignore_accept_charset_mismatch; - char *cache_vary_default_text; - char *cache_vary_default_images; - char *cache_vary_default_other; - - inkcoreapi int marshal_length(); - inkcoreapi int marshal(char *buf, int length); - int unmarshal(Arena * arena, const char *buf, int length); - - CacheLookupHttpConfig(): - cache_global_user_agent_header(false), - cache_enable_default_vary_headers(false), - ignore_accept_mismatch(false), - ignore_accept_language_mismatch(false), - ignore_accept_encoding_mismatch(false), - ignore_accept_charset_mismatch(false), - cache_vary_default_text(NULL), cache_vary_default_images(NULL), cache_vary_default_other(NULL) - { } - - void *operator new(size_t size, void *mem); - void operator delete(void *mem); -}; - -extern ClassAllocator<CacheLookupHttpConfig> CacheLookupHttpConfigAllocator; -// this is a global CacheLookupHttpConfig used to bypass SelectFromAlternates -extern CacheLookupHttpConfig global_cache_lookup_config; - -inline void * -CacheLookupHttpConfig::operator new(size_t size, void *mem) -{ - (void) size; - return mem; -} - -inline void -CacheLookupHttpConfig::operator delete(void *mem) -{ - CacheLookupHttpConfigAllocator.free((CacheLookupHttpConfig *) mem); -} - enum Variability_t { VARIABILITY_NONE = 0, @@ -97,6 +49,8 @@ enum ContentEncoding }; +struct HttpConfigParams; + class HttpTransactCache { public: @@ -105,10 +59,9 @@ public: // content negotiation support // ///////////////////////////////// - static int SelectFromAlternates(CacheHTTPInfoVector * cache_vector_data, - HTTPHdr * client_request, CacheLookupHttpConfig * cache_lookup_http_config_params); + static int SelectFromAlternates(CacheHTTPInfoVector * cache_vector_data, HTTPHdr * client_request, HttpConfigParams* http_config_params); - static float calculate_quality_of_match(CacheLookupHttpConfig * http_config_params, HTTPHdr * client_request, // in + static float calculate_quality_of_match(HttpConfigParams * http_config_params, HTTPHdr * client_request, // in HTTPHdr * obj_client_request, // in HTTPHdr * obj_origin_server_response); // in @@ -131,10 +84,8 @@ public: // variability & server negotiation routines // /////////////////////////////////////////////// - static Variability_t CalcVariability(CacheLookupHttpConfig * http_config_params, HTTPHdr * client_request, // in - HTTPHdr * obj_client_request, // in - HTTPHdr * obj_origin_server_response // in - ); + static Variability_t CalcVariability(HttpConfigParams * http_config_params, HTTPHdr * client_request, + HTTPHdr * obj_client_request, HTTPHdr * obj_origin_server_response ); static HTTPStatus match_response_to_request_conditionals(HTTPHdr * ua_request, HTTPHdr * c_response);
