]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kids.cc
2 * DEBUG: section 54 Interprocess Communication
6 #include "base/TextException.h"
9 #include "SquidConfig.h"
24 storage
.reserve(NumberOfKids());
28 // add Kid records for all workers
29 for (int i
= 0; i
< Config
.workers
; ++i
) {
30 snprintf(kid_name
, sizeof(kid_name
), "(squid-%d)", (int)(storage
.size()+1));
31 storage
.push_back(Kid(kid_name
));
34 // add Kid records for all disk processes
35 for (int i
= 0; i
< Config
.cacheSwap
.n_strands
; ++i
) {
36 snprintf(kid_name
, sizeof(kid_name
), "(squid-disk-%d)", (int)(storage
.size()+1));
37 storage
.push_back(Kid(kid_name
));
40 // if coordination is needed, add a Kid record for Coordinator
41 if (storage
.size() > 1) {
42 snprintf(kid_name
, sizeof(kid_name
), "(squid-coord-%d)", (int)(storage
.size()+1));
43 storage
.push_back(Kid(kid_name
));
46 Must(storage
.size() == static_cast<size_t>(NumberOfKids()));
49 /// returns kid by pid
50 Kid
* Kids::find(pid_t pid
)
55 for (size_t i
= 0; i
< storage
.size(); ++i
) {
56 if (storage
[i
].getPid() == pid
)
62 /// returns the kid by index, useful for kids iteration
63 Kid
& Kids::get(size_t i
)
69 /// whether all kids are hopeless
70 bool Kids::allHopeless() const
72 for (size_t i
= 0; i
< storage
.size(); ++i
) {
73 if (!storage
[i
].hopeless())
79 /// whether all kids called exited happy
80 bool Kids::allExitedHappy() const
82 for (size_t i
= 0; i
< storage
.size(); ++i
) {
83 if (!storage
[i
].exitedHappy())
89 /// whether some kids died from a given signal
90 bool Kids::someSignaled(const int sgnl
) const
92 for (size_t i
= 0; i
< storage
.size(); ++i
) {
93 if (storage
[i
].signaled(sgnl
))
99 /// whether some kids are running
100 bool Kids::someRunning() const
102 for (size_t i
= 0; i
< storage
.size(); ++i
) {
103 if (storage
[i
].running())
109 /// whether some kids should be restarted by master
110 bool Kids::shouldRestartSome() const
112 for (size_t i
= 0; i
< storage
.size(); ++i
) {
113 if (storage
[i
].shouldRestart())
119 /// returns the number of kids
120 size_t Kids::count() const
122 return storage
.size();