This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 877c5e9d14 Cleanup: Make Cache functions const (#12059)
877c5e9d14 is described below
commit 877c5e9d1417c55e9f999af5fa556976a9022de2
Author: Masaori Koshiba <[email protected]>
AuthorDate: Mon Mar 3 08:08:28 2025 +0900
Cleanup: Make Cache functions const (#12059)
---
src/iocore/cache/Cache.cc | 16 ++++++++--------
src/iocore/cache/P_CacheInternal.h | 18 +++++++++---------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc
index 71b1efd016..275eb480fe 100644
--- a/src/iocore/cache/Cache.cc
+++ b/src/iocore/cache/Cache.cc
@@ -301,7 +301,7 @@ Cache::close()
}
Action *
-Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len)
+Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(type)) {
cont->handleEvent(CACHE_EVENT_LOOKUP_FAILED, nullptr);
@@ -329,7 +329,7 @@ Cache::lookup(Continuation *cont, const CacheKey *key,
CacheFragType type, const
}
Action *
-Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len)
+Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(type)) {
cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void
*>(-ECACHE_NOT_READY));
@@ -398,7 +398,7 @@ Lcallreturn:
// main entry point for writing of non-http documents
Action *
Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType
frag_type, int options, time_t apin_in_cache,
- const char *hostname, int host_len)
+ const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(frag_type)) {
cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void
*>(-ECACHE_NOT_READY));
@@ -464,7 +464,7 @@ Cache::open_write(Continuation *cont, const CacheKey *key,
CacheFragType frag_ty
}
Action *
-Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len)
+Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(type)) {
if (cont) {
@@ -507,7 +507,7 @@ Cache::remove(Continuation *cont, const CacheKey *key,
CacheFragType type, const
}
Action *
-Cache::scan(Continuation *cont, const char *hostname, int host_len, int
KB_per_second)
+Cache::scan(Continuation *cont, const char *hostname, int host_len, int
KB_per_second) const
{
Dbg(dbg_ctl_cache_scan_truss, "inside scan");
if (!CacheProcessor::IsCacheReady(CACHE_FRAG_TYPE_HTTP)) {
@@ -532,7 +532,7 @@ Cache::scan(Continuation *cont, const char *hostname, int
host_len, int KB_per_s
Action *
Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr
*request, const HttpConfigAccessor *params,
- CacheFragType type, const char *hostname, int host_len)
+ CacheFragType type, const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(type)) {
cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void
*>(-ECACHE_NOT_READY));
@@ -607,7 +607,7 @@ Lcallreturn:
// main entry point for writing of http documents
Action *
Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo
*info, time_t apin_in_cache,
- const CacheKey * /* key1 ATS_UNUSED */, CacheFragType type,
const char *hostname, int host_len)
+ const CacheKey * /* key1 ATS_UNUSED */, CacheFragType type,
const char *hostname, int host_len) const
{
if (!CacheProcessor::IsCacheReady(type)) {
cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void
*>(-ECACHE_NOT_READY));
@@ -748,7 +748,7 @@ CacheVConnection::CacheVConnection() : VConnection(nullptr)
{}
// if generic_host_rec.stripes == nullptr, what do we do???
StripeSM *
-Cache::key_to_stripe(const CacheKey *key, const char *hostname, int host_len)
+Cache::key_to_stripe(const CacheKey *key, const char *hostname, int host_len)
const
{
ReplaceablePtr<CacheHostTable>::ScopedReader hosttable(&this->hosttable);
diff --git a/src/iocore/cache/P_CacheInternal.h
b/src/iocore/cache/P_CacheInternal.h
index 673359c6a6..c11a38d0da 100644
--- a/src/iocore/cache/P_CacheInternal.h
+++ b/src/iocore/cache/P_CacheInternal.h
@@ -450,24 +450,24 @@ struct Cache {
int total_initialized_vol = 0;
CacheType scheme = CACHE_NONE_TYPE;
- ReplaceablePtr<CacheHostTable> hosttable;
+ mutable ReplaceablePtr<CacheHostTable> hosttable;
int open(bool reconfigure, bool fix);
int close();
- Action *lookup(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len);
- Action *open_read(Continuation *cont, const CacheKey *key, CacheFragType
type, const char *hostname, int len);
+ Action *lookup(Continuation *cont, const CacheKey *key, CacheFragType type,
const char *hostname, int host_len) const;
+ Action *open_read(Continuation *cont, const CacheKey *key, CacheFragType
type, const char *hostname, int len) const;
Action *open_write(Continuation *cont, const CacheKey *key, CacheFragType
frag_type, int options = 0, time_t pin_in_cache = 0,
- const char *hostname = nullptr, int host_len = 0);
+ const char *hostname = nullptr, int host_len = 0) const;
Action *remove(Continuation *cont, const CacheKey *key, CacheFragType type =
CACHE_FRAG_TYPE_HTTP, const char *hostname = nullptr,
- int host_len = 0);
- Action *scan(Continuation *cont, const char *hostname = nullptr, int
host_len = 0, int KB_per_second = 2500);
+ int host_len = 0) const;
+ Action *scan(Continuation *cont, const char *hostname = nullptr, int
host_len = 0, int KB_per_second = 2500) const;
Action *open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr
*request, const HttpConfigAccessor *params,
- CacheFragType type, const char *hostname, int
host_len);
+ CacheFragType type, const char *hostname, int
host_len) const;
Action *open_write(Continuation *cont, const CacheKey *key,
CacheHTTPInfo *old_info, time_t pin_in_cache = 0,
const CacheKey *key1 = nullptr, CacheFragType type =
CACHE_FRAG_TYPE_HTTP, const char *hostname = nullptr,
- int host_len = 0);
+ int host_len = 0) const;
static void generate_key(CryptoHash *hash, CacheURL *url);
static void generate_key(HttpCacheKey *hash, CacheURL *url, bool
ignore_query = false, cache_generation_t generation = -1);
@@ -475,7 +475,7 @@ struct Cache {
int open_done();
- StripeSM *key_to_stripe(const CacheKey *key, const char *hostname, int
host_len);
+ StripeSM *key_to_stripe(const CacheKey *key, const char *hostname, int
host_len) const;
Cache() {}
};