diff --git a/src/base/RunnersRegistry.h b/src/base/RunnersRegistry.h index 93a2294879b..52677fc997e 100644 --- a/src/base/RunnersRegistry.h +++ b/src/base/RunnersRegistry.h @@ -70,6 +70,16 @@ class RegisteredRunner /// Meant for adjusting the module state based on configuration changes. virtual void syncConfig() {} + /* Log Rotation events */ + + /// Called after receiving a log rotate request. + /// Meant for modules that manage log files to rename/rotate them. + virtual void rotateLogs() {} + + /// Called after rotating log files. + /// Meant for modules that need to (re-)attach to log files after rotation. + virtual void finishLogRotate() {} + /* Shutdown events */ /// Called after receiving a shutdown request and before stopping the main diff --git a/src/icmp/IcmpSquid.cc b/src/icmp/IcmpSquid.cc index 3391ad23d2b..71a55c05927 100644 --- a/src/icmp/IcmpSquid.cc +++ b/src/icmp/IcmpSquid.cc @@ -10,6 +10,7 @@ #include "squid.h" #include "base/Assure.h" +#include "base/RunnersRegistry.h" #include "comm.h" #include "comm/Loops.h" #include "compat/socket.h" @@ -314,3 +315,17 @@ IcmpSquid::Close(void) #endif } +#if USE_ICMP +class IcmpRr : public RegisteredRunner +{ +public: + /* RegisteredRunner API */ + void useConfig() override { icmpEngine.Open(); } + void startReconfigure() override { icmpEngine.Close(); } + void syncConfig() override { icmpEngine.Open(); } + void rotateLogs() override { icmpEngine.Close(); } + void finishLogRotate() override { icmpEngine.Open(); } + void startShutdown() override { icmpEngine.Close(); } +}; +DefineRunnerRegistrator(IcmpRr); +#endif /* USE_ICMP */ diff --git a/src/main.cc b/src/main.cc index c9ad17f905d..9c49c7d260e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -777,7 +777,6 @@ serverConnectionsOpen(void) if (IamWorkerProcess()) { clientOpenListenSockets(); icpOpenPorts(); - icmpEngine.Open(); netdbInit(); Acl::Node::Initialize(); peerSelectInit(); @@ -792,7 +791,6 @@ serverConnectionsClose(void) if (IamWorkerProcess()) { clientConnectionsClose(); icpConnectionShutdown(); - icmpEngine.Close(); } } @@ -944,7 +942,8 @@ mainRotate(void) if (AvoidSignalAction("log rotation", do_rotate)) return; - icmpEngine.Close(); + RunRegisteredHere(RegisteredRunner::rotateLogs); + redirectShutdown(); #if USE_AUTH authenticateRotate(); @@ -959,7 +958,9 @@ mainRotate(void) #if ICAP_CLIENT icapLogRotate(); /*icap.log*/ #endif - icmpEngine.Open(); + + RunRegisteredHere(RegisteredRunner::finishLogRotate); + redirectInit(); #if USE_AUTH authenticateInit(&Auth::TheConfig.schemes);