]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/StrandCoord.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / ipc / StrandCoord.h
1 /*
2 * Copyright (C) 1996-2021 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 #ifndef SQUID_IPC_STRAND_COORD_H
10 #define SQUID_IPC_STRAND_COORD_H
11
12 #include "ipc/forward.h"
13 #include "ipc/Messages.h"
14 #include "ipc/QuestionerId.h"
15 #include "SquidString.h"
16
17 namespace Ipc
18 {
19
20 /// Strand location details
21 class StrandCoord
22 {
23 public:
24 StrandCoord(); ///< unknown location
25 StrandCoord(int akidId, pid_t aPid);
26
27 void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
28 void unpack(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
29
30 public:
31 int kidId; ///< internal Squid process number
32 pid_t pid; ///< OS process or thread identifier
33
34 String tag; ///< optional unique well-known key (e.g., cache_dir path)
35 };
36
37 /// an IPC message carrying StrandCoord
38 class StrandMessage
39 {
40 public:
41 explicit StrandMessage(const StrandCoord &, QuestionerId);
42 explicit StrandMessage(const TypedMsgHdr &);
43 void pack(MessageType, TypedMsgHdr &) const;
44
45 /// creates and sends StrandMessage to Coordinator
46 static void NotifyCoordinator(MessageType, const char *tag);
47
48 /// for Mine() tests
49 QuestionerId intendedRecepient() const { return qid; }
50
51 public:
52 StrandCoord strand; ///< messageType-specific coordinates (e.g., sender)
53
54 /// For IPC requests/questions: The sender of this request.
55 /// For IPC responses/answers: The sender of the corresponding request.
56 QuestionerId qid;
57 };
58
59 } // namespace Ipc;
60
61 #endif /* SQUID_IPC_STRAND_COORD_H */
62