]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kids.cc
4 * DEBUG: section 54 Interprocess Communication
12 char KidName
[NAME_MAX
];
20 void Kids::init(size_t n
)
24 if (storage
.size() > 0)
31 // add Kid records for all n main strands
32 for (size_t i
= 1; i
<= n
; ++i
) {
33 snprintf(kid_name
, sizeof(kid_name
), "(squid-%d)", (int)i
);
34 storage
.push_back(Kid(kid_name
));
37 // if coordination is needed, add a Kid record for Coordinator
39 snprintf(kid_name
, sizeof(kid_name
), "(squid-coord-%d)", (int)(n
+ 1));
40 storage
.push_back(Kid(kid_name
));
44 /// returns kid by pid
45 Kid
* Kids::find(pid_t pid
)
50 for (size_t i
= 0; i
< storage
.size(); ++i
) {
51 if (storage
[i
].getPid() == pid
)
57 /// returns the kid by index, useful for kids iteration
58 Kid
& Kids::get(size_t i
)
60 assert(i
>= 0 && i
< count());
64 /// whether all kids are hopeless
65 bool Kids::allHopeless() const
67 for (size_t i
= 0; i
< storage
.size(); ++i
) {
68 if (!storage
[i
].hopeless())
74 /// whether all kids called exited happy
75 bool Kids::allExitedHappy() const
77 for (size_t i
= 0; i
< storage
.size(); ++i
) {
78 if (!storage
[i
].exitedHappy())
84 /// whether all kids died from a given signal
85 bool Kids::allSignaled(int sgnl
) const
87 for (size_t i
= 0; i
< storage
.size(); ++i
) {
88 if (!storage
[i
].signaled(sgnl
))
94 /// returns the number of kids
95 size_t Kids::count() const
97 return storage
.size();