]>
Commit | Line | Data |
---|---|---|
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 | ||
20 | static CpuAffinitySet *TheCpuAffinitySet = NULL; | |
21 | ||
96c2bb61 AR |
22 | void |
23 | CpuAffinityInit() | |
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 | ||
34 | void | |
35 | CpuAffinityReconfigure() | |
36 | { | |
37 | if (TheCpuAffinitySet) { | |
38 | TheCpuAffinitySet->undo(); | |
39 | delete TheCpuAffinitySet; | |
40 | TheCpuAffinitySet = NULL; | |
41 | } | |
42 | CpuAffinityInit(); | |
43 | } | |
44 | ||
45 | void | |
46 | CpuAffinityCheck() | |
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 | } |