StrandCoord.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 54 Interprocess Communication */
10
11#include "squid.h"
12#include "debug/Stream.h"
13#include "globals.h"
14#include "ipc/Port.h"
15#include "ipc/StrandCoord.h"
16#include "ipc/TypedMsgHdr.h"
17
19{
20}
21
22Ipc::StrandCoord::StrandCoord(int aKidId, pid_t aPid): kidId(aKidId), pid(aPid)
23{
24}
25
26void
28{
29 hdrMsg.getPod(kidId);
30 hdrMsg.getPod(pid);
31 hdrMsg.getString(tag);
32}
33
35{
36 hdrMsg.putPod(kidId);
37 hdrMsg.putPod(pid);
38 hdrMsg.putString(tag);
39}
40
42 strand(aStrand),
43 qid(aQid)
44{
45}
46
48{
49 strand.unpack(hdrMsg);
50 qid.unpack(hdrMsg);
51}
52
53void
54Ipc::StrandMessage::pack(const MessageType messageType, TypedMsgHdr &hdrMsg) const
55{
56 hdrMsg.setType(messageType);
57 strand.pack(hdrMsg);
58 qid.pack(hdrMsg);
59}
60
61void
63{
64 static const auto pid = getpid();
66 if (tag)
67 message.strand.tag = tag;
68 TypedMsgHdr hdr;
69 message.pack(msgType, hdr);
71}
72
static pid_t pid
Definition: IcmpSquid.cc:34
static String CoordinatorAddr()
get the IPC message address for coordinator process
Definition: Port.cc:65
Strand location details.
Definition: StrandCoord.h:22
void unpack(const TypedMsgHdr &hdrMsg)
from recvmsg()
Definition: StrandCoord.cc:27
void pack(TypedMsgHdr &hdrMsg) const
prepare for sendmsg()
Definition: StrandCoord.cc:34
StrandCoord()
unknown location
Definition: StrandCoord.cc:18
String tag
optional unique well-known key (e.g., cache_dir path)
Definition: StrandCoord.h:34
an IPC message carrying StrandCoord
Definition: StrandCoord.h:39
StrandMessage(const StrandCoord &, QuestionerId)
Definition: StrandCoord.cc:41
void pack(MessageType, TypedMsgHdr &) const
Definition: StrandCoord.cc:54
static void NotifyCoordinator(MessageType, const char *tag)
creates and sends StrandMessage to Coordinator
Definition: StrandCoord.cc:62
StrandCoord strand
messageType-specific coordinates (e.g., sender)
Definition: StrandCoord.h:52
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
void putString(const String &s)
store variable-length string
Definition: TypedMsgHdr.cc:143
void getPod(Pod &pod) const
load POD
Definition: TypedMsgHdr.h:118
void getString(String &s) const
load variable-length string
Definition: TypedMsgHdr.cc:125
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:126
void setType(int aType)
sets message type; use MessageType enum
Definition: TypedMsgHdr.cc:100
int KidIdentifier
void SendMessage(const String &toAddress, const TypedMsgHdr &message)
Definition: UdsOp.cc:188
QuestionerId MyQuestionerId()
the questioner ID of the current/calling process
Definition: QuestionerId.cc:18
MessageType
message class identifier
Definition: Messages.h:20

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors