]>
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"
22 if (storage
.size() > 0)
25 storage
.reserve(NumberOfKids());
29 // add Kid records for all workers
30 for (int i
= 0; i
< Config
.workers
; ++i
) {
31 snprintf(kid_name
, sizeof(kid_name
), "(squid-%d)", (int)(storage
.size()+1));
32 storage
.push_back(Kid(kid_name
));
35 // add Kid records for all disk processes
36 for (int i
= 0; i
< Config
.cacheSwap
.n_strands
; ++i
) {
37 snprintf(kid_name
, sizeof(kid_name
), "(squid-disk-%d)", (int)(storage
.size()+1));
38 storage
.push_back(Kid(kid_name
));
41 // if coordination is needed, add a Kid record for Coordinator
42 if (storage
.size() > 1) {
43 snprintf(kid_name
, sizeof(kid_name
), "(squid-coord-%d)", (int)(storage
.size()+1));
44 storage
.push_back(Kid(kid_name
));
47 Must(storage
.size() == static_cast<size_t>(NumberOfKids()));
50 /// returns kid by pid
51 Kid
* Kids::find(pid_t pid
)
56 for (size_t i
= 0; i
< storage
.size(); ++i
) {
57 if (storage
[i
].getPid() == pid
)
63 /// returns the kid by index, useful for kids iteration
64 Kid
& Kids::get(size_t i
)
70 /// whether all kids are hopeless
71 bool Kids::allHopeless() const
73 for (size_t i
= 0; i
< storage
.size(); ++i
) {
74 if (!storage
[i
].hopeless())
80 /// whether all kids called exited happy
81 bool Kids::allExitedHappy() const
83 for (size_t i
= 0; i
< storage
.size(); ++i
) {
84 if (!storage
[i
].exitedHappy())
90 /// whether some kids died from a given signal
91 bool Kids::someSignaled(const int sgnl
) const
93 for (size_t i
= 0; i
< storage
.size(); ++i
) {
94 if (storage
[i
].signaled(sgnl
))
100 /// whether some kids are running
101 bool Kids::someRunning() const
103 for (size_t i
= 0; i
< storage
.size(); ++i
) {
104 if (storage
[i
].running())
110 /// whether some kids should be restarted by master
111 bool Kids::shouldRestartSome() const
113 for (size_t i
= 0; i
< storage
.size(); ++i
) {
114 if (storage
[i
].shouldRestart())
120 /// returns the number of kids
121 size_t Kids::count() const
123 return storage
.size();