]> git.ipfire.org Git - thirdparty/squid.git/blame - src/CpuAffinity.cc
Moved unlinkd-related prototypes to own header.
[thirdparty/squid.git] / src / CpuAffinity.cc
CommitLineData
96c2bb61
AR
1/*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
f7f3304a 8#include "squid.h"
96c2bb61
AR
9#include "base/TextException.h"
10#include "CpuAffinity.h"
11#include "CpuAffinityMap.h"
12#include "CpuAffinitySet.h"
582c2af2
FC
13#include "Debug.h"
14#include "protos.h"
96c2bb61 15#include "structs.h"
5bed43d6 16#include "tools.h"
96c2bb61
AR
17
18#include <algorithm>
19
20static CpuAffinitySet *TheCpuAffinitySet = NULL;
21
96c2bb61
AR
22void
23CpuAffinityInit()
24{
25 Must(!TheCpuAffinitySet);
26 if (Config.cpuAffinityMap) {
27 const int processNumber = InDaemonMode() ? KidIdentifier : 1;
28 TheCpuAffinitySet = Config.cpuAffinityMap->calculateSet(processNumber);
29 if (TheCpuAffinitySet)
30 TheCpuAffinitySet->apply();
31 }
32}
33
34void
35CpuAffinityReconfigure()
36{
37 if (TheCpuAffinitySet) {
38 TheCpuAffinitySet->undo();
39 delete TheCpuAffinitySet;
40 TheCpuAffinitySet = NULL;
41 }
42 CpuAffinityInit();
43}
44
45void
46CpuAffinityCheck()
47{
48 if (Config.cpuAffinityMap) {
49 Must(!Config.cpuAffinityMap->processes().empty());
50 const int maxProcess =
51 *std::max_element(Config.cpuAffinityMap->processes().begin(),
52 Config.cpuAffinityMap->processes().end());
53
54 // in no-deamon mode, there is one process regardless of squid.conf
55 const int numberOfProcesses = InDaemonMode() ? NumberOfKids() : 1;
56
57 if (maxProcess > numberOfProcesses) {
58 debugs(54, DBG_IMPORTANT, "WARNING: 'cpu_affinity_map' has "
59 "non-existing process number(s)");
60 }
61 }
62}