]>
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"
11 #include "ipc/SharedListen.h"
15 CBDATA_NAMESPACED_CLASS_INIT(Ipc
, Strand
);
18 Ipc::Strand::Strand():
19 Port(MakeAddr(strandAddrPfx
, KidIdentifier
)),
24 void Ipc::Strand::start()
30 void Ipc::Strand::registerSelf()
35 StrandCoord(KidIdentifier
, getpid()).pack(message
);
36 SendMessage(coordinatorAddr
, message
);
37 setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable?
40 void Ipc::Strand::receive(const TypedMsgHdr
&message
)
42 debugs(54, 6, HERE
<< message
.type());
43 switch (message
.type()) {
46 handleRegistrationResponse(StrandCoord(message
));
49 case mtSharedListenResponse
:
50 SharedListenJoined(SharedListenResponse(message
));
54 debugs(54, 1, HERE
<< "Unhandled message type: " << message
.type());
59 void Ipc::Strand::handleRegistrationResponse(const StrandCoord
&strand
)
61 // handle registration response from the coordinator; it could be stale
62 if (strand
.kidId
== KidIdentifier
&& strand
.pid
== getpid()) {
63 debugs(54, 6, "kid" << KidIdentifier
<< " registered");
64 clearTimeout(); // we are done
66 // could be an ACK to the registration message of our dead predecessor
67 debugs(54, 6, "kid" << KidIdentifier
<< " is not yet registered");
68 // keep listening, with a timeout
72 void Ipc::Strand::timedout()
74 debugs(54, 6, HERE
<< isRegistered
);
76 fatalf("kid%d registration timed out", KidIdentifier
);