Skip to content

Commit

Permalink
TS-3581: remove unused parameters from Cache::remove()
Browse files Browse the repository at this point in the history
A number of the parameters to Cache::remove() are never actually
used. We can simplify the code and make it easier to understand by
removing these.
  • Loading branch information
jpeach committed May 18, 2015
1 parent 4b60d64 commit 5bea4c4
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 6.0.0

*) [TS-3581] Remove unused parameters from Cache::remove().

*) [TS-3568] We can now assume unordered_map is always available, just need
to detect the appropriate compiler flags. This modifies the AC module too
only check for unordered_map though, since otherwise we'd never get the
Expand Down
13 changes: 6 additions & 7 deletions iocore/cache/Cache.cc
Expand Up @@ -1247,19 +1247,19 @@ CacheProcessor::open_write(Continuation *cont, CacheKey *key, bool cluster_cache

Action *
CacheProcessor::remove(Continuation *cont, CacheKey *key, bool cluster_cache_local ATS_UNUSED, CacheFragType frag_type,
bool rm_user_agents, bool rm_link, char *hostname, int host_len)
const char *hostname, int host_len)
{
Debug("cache_remove", "[CacheProcessor::remove] Issuing cache delete for %u", cache_hash(*key));
#ifdef CLUSTER_CACHE
if (cache_clustering_enabled > 0 && !cluster_cache_local) {
ClusterMachine *m = cluster_machine_at_depth(cache_hash(*key));

if (m) {
return Cluster_remove(m, cont, key, rm_user_agents, rm_link, frag_type, hostname, host_len);
return Cluster_remove(m, cont, key, frag_type, hostname, host_len);
}
}
#endif
return caches[frag_type]->remove(cont, key, frag_type, rm_user_agents, rm_link, hostname, host_len);
return caches[frag_type]->remove(cont, key, frag_type, hostname, host_len);
}

#if 0
Expand Down Expand Up @@ -3101,8 +3101,7 @@ CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
}

Action *
Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, bool /* user_agents ATS_UNUSED */,
bool /* link ATS_UNUSED */, const char *hostname, int host_len)
Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, const char *hostname, int host_len)
{
if (!CacheProcessor::IsCacheReady(type)) {
if (cont)
Expand Down Expand Up @@ -3839,12 +3838,12 @@ CacheProcessor::remove(Continuation *cont, CacheURL *url, bool cluster_cache_loc
#ifdef CLUSTER_CACHE
if (cache_clustering_enabled > 0 && !cluster_cache_local) {
// Remove from cluster
return remove(cont, &id, cluster_cache_local, frag_type, true, false, const_cast<char *>(hostname), len);
return remove(cont, &id, cluster_cache_local, frag_type, hostname, len);
}
#endif

// Remove from local cache only.
return caches[frag_type]->remove(cont, &id, frag_type, true, false, const_cast<char *>(hostname), len);
return caches[frag_type]->remove(cont, &id, frag_type, hostname, len);
}

CacheDisk *
Expand Down
2 changes: 1 addition & 1 deletion iocore/cache/CacheVol.cc
Expand Up @@ -304,7 +304,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
ink_assert(hostinfo_copied);
SET_HANDLER(&CacheVC::scanRemoveDone);
// force remove even if there is a writer
cacheProcessor.remove(this, &doc->first_key, true, CACHE_FRAG_TYPE_HTTP, true, false, (char *)hname, hlen);
cacheProcessor.remove(this, &doc->first_key, true, CACHE_FRAG_TYPE_HTTP, hname, hlen);
return EVENT_CONT;
} else {
offset = (char *)doc - buf->data();
Expand Down
3 changes: 1 addition & 2 deletions iocore/cache/I_Cache.h
Expand Up @@ -84,8 +84,7 @@ struct CacheProcessor : public Processor {
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, int expected_size = CACHE_EXPECTED_SIZE,
int options = 0, time_t pin_in_cache = (time_t)0, char *hostname = 0, int host_len = 0);
inkcoreapi Action *remove(Continuation *cont, CacheKey *key, bool cluster_cache_local,
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, bool rm_user_agents = true, bool rm_link = false,
char *hostname = 0, int host_len = 0);
CacheFragType frag_type = CACHE_FRAG_TYPE_NONE, const char *hostname = 0, int host_len = 0);
Action *scan(Continuation *cont, char *hostname = 0, int host_len = 0, int KB_per_second = SCAN_KB_PER_SECOND);
#ifdef HTTP_CACHE
Action *lookup(Continuation *cont, CacheURL *url, bool cluster_cache_local, bool local_only = false,
Expand Down
2 changes: 1 addition & 1 deletion iocore/cache/P_CacheInternal.h
Expand Up @@ -1028,7 +1028,7 @@ struct Cache {
inkcoreapi Action *open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_type, int options = 0,
time_t pin_in_cache = (time_t)0, const char *hostname = 0, int host_len = 0);
inkcoreapi Action *remove(Continuation *cont, const CacheKey *key, CacheFragType type = CACHE_FRAG_TYPE_HTTP,
bool user_agents = true, bool link = false, const char *hostname = 0, int host_len = 0);
const char *hostname = 0, int host_len = 0);
Action *scan(Continuation *cont, const char *hostname = 0, int host_len = 0, int KB_per_second = 2500);

#ifdef HTTP_CACHE
Expand Down
3 changes: 1 addition & 2 deletions iocore/cluster/ClusterCache.cc
Expand Up @@ -1316,8 +1316,7 @@ cache_op_ClusterFunction(ClusterHandler *ch, void *data, int len)
}

Cache *call_cache = caches[c->frag_type];
Action *a = call_cache->remove(c, &key, c->frag_type, !!(c->cfl_flags & CFL_REMOVE_USER_AGENTS),
!!(c->cfl_flags & CFL_REMOVE_LINK), hostname, host_len);
Action *a = call_cache->remove(c, &key, c->frag_type, hostname, host_len);
if (a != ACTION_RESULT_DONE) {
c->cache_action = a;
}
Expand Down
4 changes: 2 additions & 2 deletions iocore/cluster/P_ClusterCacheInternal.h
Expand Up @@ -324,8 +324,8 @@ struct CacheContinuation : public Continuation {
// Bit definitions for cfl_flags.
// Note: Limited to 16 bits
#define CFL_OVERWRITE_ON_WRITE (1 << 1)
#define CFL_REMOVE_USER_AGENTS (1 << 2)
#define CFL_REMOVE_LINK (1 << 3)
#define CFL_REMOVE_USER_AGENTS (1 << 2) // Historical, now unused
#define CFL_REMOVE_LINK (1 << 3) // Historical, now unused
#define CFL_LOPENWRITE_HAVE_OLDINFO (1 << 4)
#define CFL_ALLOW_MULTIPLE_WRITES (1 << 5)
#define CFL_MAX (1 << 15)
Expand Down
6 changes: 2 additions & 4 deletions iocore/cluster/P_ClusterInline.h
Expand Up @@ -343,8 +343,7 @@ Cluster_deref(ClusterMachine *m, Continuation *cont, CacheKey *key, CacheFragTyp
}

inline Action *
Cluster_remove(ClusterMachine *m, Continuation *cont, CacheKey *key, bool rm_user_agents, bool rm_link, CacheFragType frag_type,
char *hostname, int host_len)
Cluster_remove(ClusterMachine *m, Continuation *cont, CacheKey *key, CacheFragType frag_type, const char *hostname, int host_len)
{
if (clusterProcessor.disable_remote_cluster_ops(m)) {
Action a;
Expand All @@ -368,9 +367,8 @@ Cluster_remove(ClusterMachine *m, Continuation *cont, CacheKey *key, bool rm_use

// Setup args for remote update
CacheOpArgs_General updateArgs;
ink_zero(updateArgs);
updateArgs.url_md5 = key;
updateArgs.cfl_flags |= (rm_user_agents ? CFL_REMOVE_USER_AGENTS : 0);
updateArgs.cfl_flags |= (rm_link ? CFL_REMOVE_LINK : 0);
updateArgs.frag_type = frag_type;
return CacheContinuation::do_op(cont, m, (void *)&updateArgs, CACHE_REMOVE, msg, (flen + len));
} else {
Expand Down
2 changes: 1 addition & 1 deletion proxy/InkAPI.cc
Expand Up @@ -6709,7 +6709,7 @@ TSCacheRemove(TSCont contp, TSCacheKey key)
CacheInfo *info = (CacheInfo *)key;
INKContInternal *i = (INKContInternal *)contp;

return (TSAction)cacheProcessor.remove(i, &info->cache_key, true, info->frag_type, true, false, info->hostname, info->len);
return (TSAction)cacheProcessor.remove(i, &info->cache_key, true, info->frag_type, info->hostname, info->len);
}

TSAction
Expand Down

0 comments on commit 5bea4c4

Please sign in to comment.