]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Strand.cc
4 * DEBUG: section 54 Interprocess Communication
9 #include "ipc/Strand.h"
10 #include "ipc/Messages.h"
14 CBDATA_NAMESPACED_CLASS_INIT(Ipc
, Strand
);
17 Ipc::Strand::Strand():
18 Port(MakeAddr(strandAddrPfx
, KidIdentifier
)),
23 void Ipc::Strand::start()
29 void Ipc::Strand::registerSelf()
34 StrandCoord(KidIdentifier
, getpid()).pack(message
);
35 SendMessage(coordinatorAddr
, message
);
36 setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable?
39 void Ipc::Strand::receive(const TypedMsgHdr
&message
)
42 switch (message
.type()) {
45 handleRegistrationResponse(StrandCoord(message
));
49 debugs(54, 6, HERE
<< "Unhandled message type: " << message
.type());
54 void Ipc::Strand::handleRegistrationResponse(const StrandCoord
&strand
)
56 // handle registration response from the coordinator; it could be stale
57 if (strand
.kidId
== KidIdentifier
&& strand
.pid
== getpid()) {
58 debugs(54, 6, "kid" << KidIdentifier
<< " registered");
59 clearTimeout(); // we are done
61 // could be an ACK to the registration message of our dead predecessor
62 debugs(54, 6, "kid" << KidIdentifier
<< " is not yet registered");
63 // keep listening, with a timeout
67 void Ipc::Strand::timedout()
69 debugs(54, 6, HERE
<< isRegistered
);
71 fatalf("kid%d registration timed out", KidIdentifier
);