diff --git a/include/ts/ts.h b/include/ts/ts.h index d36586701e1..61e7d45e251 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -2485,6 +2485,7 @@ tsapi TSReturnCode TSHttpTxnCacheLookupStatusSet(TSHttpTxn txnp, int cachelookup tsapi TSReturnCode TSHttpTxnCacheLookupUrlGet(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc obj); tsapi TSReturnCode TSHttpTxnCacheLookupUrlSet(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc obj); tsapi TSReturnCode TSHttpTxnPrivateSessionSet(TSHttpTxn txnp, int private_session); +tsapi const char *TSHttpTxnCacheDiskPathGet(TSHttpTxn txnp, int *length); tsapi int TSHttpTxnBackgroundFillStarted(TSHttpTxn txnp); tsapi int TSHttpTxnIsWebsocket(TSHttpTxn txnp); diff --git a/iocore/cache/I_Cache.h b/iocore/cache/I_Cache.h index d38716a45b0..0586d8c23d7 100644 --- a/iocore/cache/I_Cache.h +++ b/iocore/cache/I_Cache.h @@ -205,6 +205,12 @@ struct CacheVConnection : public VConnection { return -1; } + virtual const char * + get_disk_path() const + { + return nullptr; + } + /** Test if the VC can support pread. @return @c true if @c do_io_pread will work, @c false if not. */ diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h index 69d26a9461a..19ebb62706d 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -294,6 +294,16 @@ struct CacheVC : public CacheVConnection { return -1; } + const char * + get_disk_path() const override + { + if (vol && vol->disk) { + return vol->disk->path; + } + + return nullptr; + } + bool is_compressed_in_ram() const override { diff --git a/proxy/http/HttpCacheSM.h b/proxy/http/HttpCacheSM.h index 2fc0c0ec2aa..aa00e1923fe 100644 --- a/proxy/http/HttpCacheSM.h +++ b/proxy/http/HttpCacheSM.h @@ -138,6 +138,18 @@ class HttpCacheSM : public Continuation return cache_read_vc ? (cache_read_vc->get_volume_number()) : -1; } + const char * + get_disk_path() + { + if (cache_read_vc) { + return cache_read_vc->get_disk_path(); + } else if (cache_write_vc) { + return cache_write_vc->get_disk_path(); + } + + return nullptr; + } + inline void abort_read() { diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index ec7ed4e42d1..d4fa9fb8a04 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -5489,6 +5489,35 @@ TSHttpTxnIsWebsocket(TSHttpTxn txnp) return sm->t_state.is_websocket; } +const char * +TSHttpTxnCacheDiskPathGet(TSHttpTxn txnp, int *length) +{ + sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); + + HttpSM *s = reinterpret_cast(txnp); + HttpCacheSM *c_sm = &(s->get_cache_sm()); + + if (!c_sm) { + if (length != nullptr) { + *length = 0; + } + + return nullptr; + } + + const char *path = c_sm->get_disk_path(); + + if (length != nullptr) { + if (path != nullptr) { + *length = strlen(path); + } else { + *length = 0; + } + } + + return path; +} + TSReturnCode TSHttpTxnCacheLookupUrlGet(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc obj) {