From 753ee74b11326b4f0e81e7fb6cd99e4c44c539c1 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 30 Apr 2024 09:33:19 +1200 Subject: [PATCH 1/2] Maintenance: add ostream report API to Mgr::Action This new API method allows new or updated cache manager reports to write their output to a stream without having to import any StoreEntry related API. --- src/mgr/Action.cc | 9 ++++++++- src/mgr/Action.h | 9 ++++++++- src/tests/stub_libmgr.cc | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mgr/Action.cc b/src/mgr/Action.cc index 2c8bf63bf57..35e75003972 100644 --- a/src/mgr/Action.cc +++ b/src/mgr/Action.cc @@ -9,6 +9,7 @@ /* DEBUG: section 16 Cache Manager API */ #include "squid.h" +#include "base/PackableStream.h" #include "CacheManager.h" #include "comm/Connection.h" #include "HttpReply.h" @@ -112,7 +113,7 @@ Mgr::Action::fillEntry(StoreEntry* entry, bool writeHttpHeader) entry->replaceHttpReply(rep); } - dump(entry); + dump(entry); // TODO: replace with report() when all children are converted entry->flush(); @@ -120,3 +121,9 @@ Mgr::Action::fillEntry(StoreEntry* entry, bool writeHttpHeader) entry->complete(); } +void +Mgr::Action::dump(StoreEntry *entry) +{ + PackableStream os(*entry); + report(os); +} diff --git a/src/mgr/Action.h b/src/mgr/Action.h index bf09b0e1519..407d36af72f 100644 --- a/src/mgr/Action.h +++ b/src/mgr/Action.h @@ -14,6 +14,8 @@ #include "ipc/forward.h" #include "mgr/forward.h" +#include + class StoreEntry; namespace Mgr @@ -76,11 +78,16 @@ class Action: public RefCountable /// calculate and keep local action-specific information virtual void collect() {} + /// write manager report output to a stream. + virtual void report(std::ostream &) {} + /** start writing action-specific info to Store entry; * may collect info during dump, especially if collect() did nothing * non-atomic() actions may continue writing asynchronously after returning + * + * \deprecated implement report() instead */ - virtual void dump(StoreEntry *) {} + virtual void dump(StoreEntry *); private: const CommandPointer cmd; ///< the command that caused this action diff --git a/src/tests/stub_libmgr.cc b/src/tests/stub_libmgr.cc index 8177995bd7c..fc9af989269 100644 --- a/src/tests/stub_libmgr.cc +++ b/src/tests/stub_libmgr.cc @@ -34,6 +34,7 @@ const char * Mgr::Action::name() const STUB_RETVAL(nullptr) static Mgr::Command static_Command; const Mgr::Command & Mgr::Action::command() const STUB_RETVAL(static_Command) StoreEntry * Mgr::Action::createStoreEntry() const STUB_RETVAL(nullptr) +void Mgr::Action::dump(StoreEntry *) STUB static Mgr::Action::Pointer dummyAction; #include "mgr/ActionParams.h" From 58d9f912e62d1bde80997698c990e9096d891095 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Wed, 8 May 2024 00:26:05 +1200 Subject: [PATCH 2/2] Remove code comment Apparently marking an unwanted API as deprecated is enough to seriously break Squid somehow. --- src/mgr/Action.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mgr/Action.h b/src/mgr/Action.h index 407d36af72f..9100f32cad6 100644 --- a/src/mgr/Action.h +++ b/src/mgr/Action.h @@ -84,8 +84,6 @@ class Action: public RefCountable /** start writing action-specific info to Store entry; * may collect info during dump, especially if collect() did nothing * non-atomic() actions may continue writing asynchronously after returning - * - * \deprecated implement report() instead */ virtual void dump(StoreEntry *);