diff --git a/include/ts/ts.h b/include/ts/ts.h index a74f65ce145..a6f17af43fa 100644 --- a/include/ts/ts.h +++ b/include/ts/ts.h @@ -2486,6 +2486,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 70f670537d8..68714b55c0b 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -293,6 +293,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 9add57fa26a..29a66ae144d 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 ef495cb3d11..09a6bd0ab60 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -5551,6 +5551,24 @@ 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 *sm = reinterpret_cast(txnp); + char const *path = nullptr; + + if (HttpCacheSM *c_sm = &(sm->get_cache_sm()); c_sm) { + path = c_sm->get_disk_path(); + } + if (length) { + *length = path ? strlen(path) : 0; + } + + return path; +} + TSReturnCode TSHttpTxnCacheLookupUrlGet(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc obj) {