]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Port.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / ipc / Port.h
1 /*
2 * Copyright (C) 1996-2014 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 #ifndef SQUID_IPC_PORT_H
12 #define SQUID_IPC_PORT_H
13
14 #include "ipc/UdsOp.h"
15 #include "SquidString.h"
16
17 namespace Ipc
18 {
19
20 /// Waits for and receives incoming IPC messages; kids handle the messages
21 class Port: public UdsOp
22 {
23 public:
24 Port(const String &aListenAddr);
25 /// calculates IPC message address for strand #id of processLabel type
26 static String MakeAddr(const char *proccessLabel, int id);
27
28 /// get the IPC message address for coordinator process
29 static String CoordinatorAddr();
30
31 protected:
32 virtual void start() = 0; // UdsOp (AsyncJob) API; has body
33 virtual bool doneAll() const; // UdsOp (AsyncJob) API
34
35 /// read the next incoming message
36 void doListen();
37
38 /// handle IPC message just read
39 virtual void receive(const TypedMsgHdr& message) = 0;
40
41 private:
42 void noteRead(const CommIoCbParams &params); // Comm callback API
43
44 private:
45 TypedMsgHdr buf; ///< msghdr struct filled by Comm
46 };
47
48 extern const char strandAddrLabel[]; ///< strand's listening address unique label
49
50 } // namespace Ipc
51
52 #endif /* SQUID_IPC_PORT_H */