Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/base/RunnersRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/icmp/IcmpSquid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
9 changes: 5 additions & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,6 @@ serverConnectionsOpen(void)
if (IamWorkerProcess()) {
clientOpenListenSockets();
icpOpenPorts();
icmpEngine.Open();
netdbInit();
Acl::Node::Initialize();
peerSelectInit();
Expand All @@ -792,7 +791,6 @@ serverConnectionsClose(void)
if (IamWorkerProcess()) {
clientConnectionsClose();
icpConnectionShutdown();
icmpEngine.Close();
}
}

Expand Down Expand Up @@ -944,7 +942,8 @@ mainRotate(void)
if (AvoidSignalAction("log rotation", do_rotate))
return;

icmpEngine.Close();
RunRegisteredHere(RegisteredRunner::rotateLogs);

redirectShutdown();
#if USE_AUTH
authenticateRotate();
Expand All @@ -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);
Expand Down
Loading