/* Reconfiguration events */
+ /// Called after receiving a reconfigure request and before parsing squid.conf.
+ /// Meant for modules that need to prepare for their configuration being changed
+ /// [outside their control]. The changes end with the syncConfig() event.
+ virtual void startReconfigure() {}
+
/// Called after parsing squid.conf during reconfiguration.
/// Meant for adjusting the module state based on configuration changes.
virtual void syncConfig() {}
#include "squid.h"
#include "base/InstanceId.h"
+#include "base/RunnersRegistry.h"
#include "comm.h"
#include "comm/Connection.h"
#include "comm/ConnOpener.h"
nsvc *vc;
};
+namespace Dns
+{
+
+/// manage DNS internal component
+class ConfigRr : public RegisteredRunner
+{
+public:
+ /* RegisteredRunner API */
+ virtual void startReconfigure() override;
+ virtual void endingShutdown() override;
+};
+
+RunnerRegistrationEntry(ConfigRr);
+
+} // namespace Dns
+
struct _sp {
char domain[NS_MAXDNAME];
int queries;
{
delete queue;
delete msg;
- if (ns < nns) // XXX: Dns::Shutdown may have freed nameservers[]
+ if (ns < nns) // XXX: idnsShutdownAndFreeState may have freed nameservers[]
nameservers[ns].vc = NULL;
}
static void
idnsSendQuery(idns_query * q)
{
+ // XXX: DNS sockets get closed during reconfigure produces a race between
+ // any already active connections (or ones received between closing DNS
+ // sockets and server listening sockets) and the reconfigure completing
+ // (Runner syncConfig() being run). Transactions which loose this race will
+ // produce DNS timeouts (or whatever the caller set) as their queries never
+ // get queued to be re-tried after the DNS socekts are re-opened.
+
if (DnsSocketA < 0 && DnsSocketB < 0) {
debugs(78, DBG_IMPORTANT, "WARNING: idnsSendQuery: Can't send query, no DNS socket!");
return;
Mgr::RegisterAction("idns", "Internal DNS Statistics", idnsStats, 0, 1);
}
-void
-Dns::Shutdown(void)
+static void
+idnsShutdownAndFreeState(const char *reason)
{
if (DnsSocketA < 0 && DnsSocketB < 0)
return;
+ debugs(78, 2, reason << ": Closing DNS sockets");
+
if (DnsSocketA >= 0 ) {
comm_close(DnsSocketA);
DnsSocketA = -1;
idnsFreeSearchpath();
}
+void
+Dns::ConfigRr::endingShutdown()
+{
+ idnsShutdownAndFreeState("Shutdown");
+}
+
+void
+Dns::ConfigRr::startReconfigure()
+{
+ idnsShutdownAndFreeState("Reconfigure");
+}
+
static int
idnsCachedLookup(const char *key, IDNSCB * callback, void *data)
{
debugs(1, DBG_IMPORTANT, "Reconfiguring Squid Cache (version " << version_string << ")...");
reconfiguring = 1;
+ RunRegisteredHere(RegisteredRunner::startReconfigure);
+
// Initiate asynchronous closing sequence
serverConnectionsClose();
icpClosePorts();
#if USE_HTCP
htcpClosePorts();
#endif
- Dns::Shutdown();
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Shutdown();
#endif
#endif
debugs(1, DBG_IMPORTANT, "Shutting down...");
- Dns::Shutdown();
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Shutdown();
#endif