/*
- * DEBUG: section 54 Interprocess Communication
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+/* DEBUG: section 54 Interprocess Communication */
+
#include "squid.h"
#include "Debug.h"
-#include "ipc/Messages.h"
+#include "globals.h"
+#include "ipc/Port.h"
#include "ipc/StrandCoord.h"
#include "ipc/TypedMsgHdr.h"
hdrMsg.putString(tag);
}
-Ipc::HereIamMessage::HereIamMessage(const StrandCoord &aStrand):
- strand(aStrand)
+Ipc::StrandMessage::StrandMessage(const StrandCoord &aStrand, const QuestionerId aQid):
+ strand(aStrand),
+ qid(aQid)
{
}
-Ipc::HereIamMessage::HereIamMessage(const TypedMsgHdr &hdrMsg)
+Ipc::StrandMessage::StrandMessage(const TypedMsgHdr &hdrMsg)
{
- hdrMsg.checkType(mtRegistration);
strand.unpack(hdrMsg);
+ qid.unpack(hdrMsg);
}
-void Ipc::HereIamMessage::pack(TypedMsgHdr &hdrMsg) const
+void
+Ipc::StrandMessage::pack(const MessageType messageType, TypedMsgHdr &hdrMsg) const
{
- hdrMsg.setType(mtRegistration);
+ hdrMsg.setType(messageType);
strand.pack(hdrMsg);
+ qid.pack(hdrMsg);
}
+
+void
+Ipc::StrandMessage::NotifyCoordinator(const MessageType msgType, const char *tag)
+{
+ static const auto pid = getpid();
+ StrandMessage message(StrandCoord(KidIdentifier, pid), MyQuestionerId());
+ if (tag)
+ message.strand.tag = tag;
+ TypedMsgHdr hdr;
+ message.pack(msgType, hdr);
+ SendMessage(Port::CoordinatorAddr(), hdr);
+}
+