]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Strand.cc
4 * DEBUG: section 54 Interprocess Communication
9 #include "base/TextException.h"
10 #include "ipc/Strand.h"
11 #include "ipc/Messages.h"
12 #include "ipc/SharedListen.h"
16 CBDATA_NAMESPACED_CLASS_INIT(Ipc
, Strand
);
19 Ipc::Strand::Strand():
20 Port(MakeAddr(strandAddrPfx
, KidIdentifier
)),
25 void Ipc::Strand::start()
31 void Ipc::Strand::registerSelf()
36 StrandCoord(KidIdentifier
, getpid()).pack(message
);
37 SendMessage(coordinatorAddr
, message
);
38 setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable?
41 void Ipc::Strand::receive(const TypedMsgHdr
&message
)
43 debugs(54, 6, HERE
<< message
.type());
44 switch (message
.type()) {
47 handleRegistrationResponse(StrandCoord(message
));
50 case mtSharedListenResponse
:
51 SharedListenJoined(SharedListenResponse(message
));
55 debugs(54, 1, HERE
<< "Unhandled message type: " << message
.type());
60 void Ipc::Strand::handleRegistrationResponse(const StrandCoord
&strand
)
62 // handle registration response from the coordinator; it could be stale
63 if (strand
.kidId
== KidIdentifier
&& strand
.pid
== getpid()) {
64 debugs(54, 6, "kid" << KidIdentifier
<< " registered");
65 clearTimeout(); // we are done
67 // could be an ACK to the registration message of our dead predecessor
68 debugs(54, 6, "kid" << KidIdentifier
<< " is not yet registered");
69 // keep listening, with a timeout
73 void Ipc::Strand::timedout()
75 debugs(54, 6, HERE
<< isRegistered
);
77 fatalf("kid%d registration timed out", KidIdentifier
);