*
*/
-#include "squid.h"
+#include "squid-old.h"
#include "AccessLogEntry.h"
#if USE_ADAPTATION
#include "adaptation/Config.h"
#include "event.h"
#include "EventLoop.h"
#include "ExternalACL.h"
+#include "format/Token.h"
#include "fs/Module.h"
#include "PeerSelectState.h"
+#include "SquidDns.h"
#include "Store.h"
#include "ICP.h"
#include "ident/Ident.h"
#include "ipc/Strand.h"
#include "ip/tools.h"
#include "SquidTime.h"
+#include "StatCounters.h"
#include "SwapDir.h"
#include "forward.h"
#include "MemPool.h"
opt_send_signal = SIGHUP;
else if (!strncmp(optarg, "rotate", strlen(optarg)))
/** \li On rotate send SIGQUIT or SIGUSR1. */
-#ifdef _SQUID_LINUX_THREADS_
-
+#if defined(_SQUID_LINUX_THREADS_)
opt_send_signal = SIGQUIT;
-
#else
-
opt_send_signal = SIGUSR1;
-
#endif
else if (!strncmp(optarg, "debug", strlen(optarg)))
/** \li On debug send SIGTRAP or SIGUSR2. */
-#ifdef _SQUID_LINUX_THREADS_
-
+#if defined(_SQUID_LINUX_THREADS_)
opt_send_signal = SIGTRAP;
-
#else
-
opt_send_signal = SIGUSR2;
-
#endif
else if (!strncmp(optarg, "shutdown", strlen(optarg)))
wccp2ConnectionOpen();
#endif
}
- // Coordinator does not start proxying services
- if (!IamCoordinatorProcess()) {
+ // start various proxying services if we are responsible for them
+ if (IamWorkerProcess()) {
clientOpenListenSockets();
icpConnectionsOpen();
#if USE_HTCP
htcpInit();
#endif
#if SQUID_SNMP
-
snmpConnectionOpen();
#endif
wccp2ConnectionClose();
#endif
}
- if (!IamCoordinatorProcess()) {
+ if (IamWorkerProcess()) {
clientHttpConnectionsClose();
icpConnectionShutdown();
#if USE_HTCP
icmpEngine.Close();
#if SQUID_SNMP
-
- snmpConnectionShutdown();
+ snmpConnectionClose();
#endif
asnFreeMemory();
htcpSocketClose();
#endif
-#if SQUID_SNMP
-
- snmpConnectionClose();
-#endif
-#if USE_DNSSERVERS
-
dnsShutdown();
-#else
-
- idnsShutdown();
-#endif
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Shutdown();
#endif
icapLogOpen();
#endif
storeLogOpen();
-#if USE_DNSSERVERS
-
dnsInit();
-#else
-
- idnsInit();
-#endif
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Init();
#endif
mimeInit(Config.mimeTablePathname);
+#if USE_UNLINKD
+ if (unlinkdNeeded())
+ unlinkdInit();
+#endif
+
#if USE_DELAY_POOLS
Config.ClientDelay.finalize();
#endif
mainRotate(void)
{
icmpEngine.Close();
-#if USE_DNSSERVERS
+#if USE_DNSHELPER
dnsShutdown();
#endif
redirectShutdown();
icapLogRotate(); /*icap.log*/
#endif
icmpEngine.Open();
-#if USE_DNSSERVERS
+#if USE_DNSHELPER
dnsInit();
#endif
redirectInit();
#endif
debugs(1, 1, "Process ID " << getpid());
+
+ debugs(1, 1, "Process Roles:" << ProcessRoles());
+
setSystemLimits();
debugs(1, 1, "With " << Squid_MaxFD << " file descriptors available");
parseEtcHosts();
-#if USE_DNSSERVERS
-
dnsInit();
-#else
-
- idnsInit();
-
-#endif
-
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Init();
#endif
if (!configured_once) {
#if USE_UNLINKD
- unlinkdInit();
+ if (unlinkdNeeded())
+ unlinkdInit();
#endif
urlInitialize();
if (!configured_once)
writePidFile(); /* write PID file */
-#ifdef _SQUID_LINUX_THREADS_
+#if defined(_SQUID_LINUX_THREADS_)
squid_signal(SIGQUIT, rotate_logs, SA_RESTART);
try {
return SquidMain(argc, argv);
} catch (const std::exception &e) {
- std::cerr << "dying from an unhandled exception: " << e.what() << std::endl;
+ debugs(1, DBG_CRITICAL, "FATAL: dying from an unhandled exception: " <<
+ e.what());
throw;
} catch (...) {
- std::cerr << "dying from an unhandled exception." << std::endl;
+ debugs(1, DBG_CRITICAL, "FATAL: dying from an unhandled exception.");
throw;
}
return -1; // not reached
const size_t nameLen = idStart - (processName + 1);
assert(nameLen < sizeof(TheKidName));
xstrncpy(TheKidName, processName + 1, nameLen + 1);
+ if (!strcmp(TheKidName, "squid-coord"))
+ TheProcessKind = pkCoordinator;
+ else if (!strcmp(TheKidName, "squid"))
+ TheProcessKind = pkWorker;
+ else if (!strcmp(TheKidName, "squid-disk"))
+ TheProcessKind = pkDisker;
+ else
+ TheProcessKind = pkOther; // including coordinator
}
} else {
xstrncpy(TheKidName, APP_SHORTNAME, sizeof(TheKidName));
#endif
Ip::ProbeTransport(); // determine IPv4 or IPv6 capabilities before parsing.
+ Format::Token::Init(); // XXX: temporary. Use a runners registry of pre-parse runners instead.
+
parse_err = parseConfigFile(ConfigFile);
Mem::Report();
debugs(1,2, HERE << "Doing post-config initialization\n");
leave_suid();
+ ActivateRegistered(rrClaimMemoryNeeds);
ActivateRegistered(rrAfterConfig);
enter_suid();
if (IamCoordinatorProcess())
AsyncJob::Start(Ipc::Coordinator::Instance());
- else if (UsingSmp() && IamWorkerProcess())
+ else if (UsingSmp() && (IamWorkerProcess() || IamDiskProcess()))
AsyncJob::Start(new Ipc::Strand);
/* at this point we are finished the synchronous startup. */
Config.workers);
// but we keep going in hope that user knows best
}
- TheKids.init(Config.workers);
+ TheKids.init();
+
+ syslog(LOG_NOTICE, "Squid Parent: will start %d kids", (int)TheKids.count());
// keep [re]starting kids until it is time to quit
for (;;) {
}
kid.start(pid);
- syslog(LOG_NOTICE, "Squid Parent: child process %d started", pid);
+ syslog(LOG_NOTICE, "Squid Parent: %s process %d started",
+ kid.name().termedBuf(), pid);
}
/* parent */
kid->stop(status);
if (kid->calledExit()) {
syslog(LOG_NOTICE,
- "Squid Parent: child process %d exited with status %d",
+ "Squid Parent: %s process %d exited with status %d",
+ kid->name().termedBuf(),
kid->getPid(), kid->exitStatus());
} else if (kid->signaled()) {
syslog(LOG_NOTICE,
- "Squid Parent: child process %d exited due to signal %d with status %d",
+ "Squid Parent: %s process %d exited due to signal %d with status %d",
+ kid->name().termedBuf(),
kid->getPid(), kid->termSignal(), kid->exitStatus());
} else {
- syslog(LOG_NOTICE, "Squid Parent: child process %d exited", kid->getPid());
+ syslog(LOG_NOTICE, "Squid Parent: %s process %d exited",
+ kid->name().termedBuf(), kid->getPid());
}
if (kid->hopeless()) {
- syslog(LOG_NOTICE, "Squid Parent: child process %d will not"
+ syslog(LOG_NOTICE, "Squid Parent: %s process %d will not"
" be restarted due to repeated, frequent failures",
- kid->getPid());
+ kid->name().termedBuf(), kid->getPid());
}
} else {
syslog(LOG_NOTICE, "Squid Parent: unknown child process %d exited", pid);
if (!TheKids.someRunning() && !TheKids.shouldRestartSome()) {
leave_suid();
DeactivateRegistered(rrAfterConfig);
+ DeactivateRegistered(rrClaimMemoryNeeds);
enter_suid();
if (TheKids.someSignaled(SIGINT) || TheKids.someSignaled(SIGTERM)) {
#endif
debugs(1, 1, "Shutting down...");
-#if USE_DNSSERVERS
-
dnsShutdown();
-#else
-
- idnsShutdown();
-#endif
#if USE_SSL_CRTD
Ssl::Helper::GetInstance()->Shutdown();
#endif
htcpSocketClose();
#endif
#if SQUID_SNMP
-
snmpConnectionClose();
#endif
#if USE_WCCP
StoreFileSystem::FreeAllFs();
DiskIOModule::FreeAllModules();
DeactivateRegistered(rrAfterConfig);
+ DeactivateRegistered(rrClaimMemoryNeeds);
#if LEAK_CHECK_MODE && 0 /* doesn't work at the moment */
configFreeMemory();