]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kids.cc
2 * DEBUG: section 54 Interprocess Communication
6 #include "base/TextException.h"
10 #include "SquidConfig.h"
23 if (storage
.size() > 0)
26 storage
.reserve(NumberOfKids());
30 // add Kid records for all workers
31 for (int i
= 0; i
< Config
.workers
; ++i
) {
32 snprintf(kid_name
, sizeof(kid_name
), "(squid-%d)", (int)(storage
.size()+1));
33 storage
.push_back(Kid(kid_name
));
36 // add Kid records for all disk processes
37 for (int i
= 0; i
< Config
.cacheSwap
.n_strands
; ++i
) {
38 snprintf(kid_name
, sizeof(kid_name
), "(squid-disk-%d)", (int)(storage
.size()+1));
39 storage
.push_back(Kid(kid_name
));
42 // if coordination is needed, add a Kid record for Coordinator
43 if (storage
.size() > 1) {
44 snprintf(kid_name
, sizeof(kid_name
), "(squid-coord-%d)", (int)(storage
.size()+1));
45 storage
.push_back(Kid(kid_name
));
48 Must(storage
.size() == static_cast<size_t>(NumberOfKids()));
51 /// returns kid by pid
52 Kid
* Kids::find(pid_t pid
)
57 for (size_t i
= 0; i
< storage
.size(); ++i
) {
58 if (storage
[i
].getPid() == pid
)
64 /// returns the kid by index, useful for kids iteration
65 Kid
& Kids::get(size_t i
)
71 /// whether all kids are hopeless
72 bool Kids::allHopeless() const
74 for (size_t i
= 0; i
< storage
.size(); ++i
) {
75 if (!storage
[i
].hopeless())
81 /// whether all kids called exited happy
82 bool Kids::allExitedHappy() const
84 for (size_t i
= 0; i
< storage
.size(); ++i
) {
85 if (!storage
[i
].exitedHappy())
91 /// whether some kids died from a given signal
92 bool Kids::someSignaled(const int sgnl
) const
94 for (size_t i
= 0; i
< storage
.size(); ++i
) {
95 if (storage
[i
].signaled(sgnl
))
101 /// whether some kids are running
102 bool Kids::someRunning() const
104 for (size_t i
= 0; i
< storage
.size(); ++i
) {
105 if (storage
[i
].running())
111 /// whether some kids should be restarted by master
112 bool Kids::shouldRestartSome() const
114 for (size_t i
= 0; i
< storage
.size(); ++i
) {
115 if (storage
[i
].shouldRestart())
121 /// returns the number of kids
122 size_t Kids::count() const
124 return storage
.size();