]>
Commit | Line | Data |
---|---|---|
0d0bce6a | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
0d0bce6a | 3 | * |
bbc27441 AJ |
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. | |
0d0bce6a AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 54 Interprocess Communication */ |
10 | ||
0d0bce6a AR |
11 | #ifndef SQUID_IPC_SHARED_LISTEN_H |
12 | #define SQUID_IPC_SHARED_LISTEN_H | |
13 | ||
14 | #include "base/AsyncCall.h" | |
25b481e6 | 15 | #include "base/Subscription.h" |
0d0bce6a AR |
16 | |
17 | namespace Ipc | |
18 | { | |
19 | ||
20 | /// "shared listen" is when concurrent processes are listening on the same fd | |
21 | ||
e0d28505 AJ |
22 | /// Comm::ConnAcceptor parameters holder |
23 | /// all the details necessary to recreate a Comm::Connection and fde entry for the kid listener FD | |
0d0bce6a AR |
24 | class OpenListenerParams |
25 | { | |
26 | public: | |
27 | OpenListenerParams(); | |
28 | ||
29 | bool operator <(const OpenListenerParams &p) const; ///< useful for map<> | |
30 | ||
e0d28505 | 31 | // bits to re-create the fde entry |
0d0bce6a AR |
32 | int sock_type; |
33 | int proto; | |
e0d28505 AJ |
34 | int fdNote; ///< index into fd_note() comment strings |
35 | ||
36 | // bits to re-create the listener Comm::Connection descriptor | |
a67d2b2e | 37 | Ip::Address addr; ///< will be memset and memcopied |
0d0bce6a | 38 | int flags; |
e0d28505 AJ |
39 | |
40 | /// handler to subscribe to Comm::ConnAcceptor when we get the response | |
41 | Subscription::Pointer handlerSubscription; | |
0d0bce6a AR |
42 | }; |
43 | ||
44 | class TypedMsgHdr; | |
45 | ||
46 | /// a request for a listen socket with given parameters | |
47 | class SharedListenRequest | |
48 | { | |
49 | public: | |
50 | SharedListenRequest(); ///< from OpenSharedListen() which then sets public data | |
51 | explicit SharedListenRequest(const TypedMsgHdr &hdrMsg); ///< from recvmsg() | |
52 | void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() | |
53 | ||
54 | public: | |
55 | int requestorId; ///< kidId of the requestor | |
56 | ||
57 | OpenListenerParams params; ///< actual comm_open_sharedListen() parameters | |
58 | ||
59 | int mapId; ///< to map future response to the requestor's callback | |
60 | }; | |
61 | ||
62 | /// a response to SharedListenRequest | |
63 | class SharedListenResponse | |
64 | { | |
65 | public: | |
b72fb55d | 66 | SharedListenResponse(int fd, int errNo, int mapId); |
0d0bce6a AR |
67 | explicit SharedListenResponse(const TypedMsgHdr &hdrMsg); ///< from recvmsg() |
68 | void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() | |
69 | ||
70 | public: | |
b72fb55d | 71 | int fd; ///< opened listening socket or -1 |
0d0bce6a AR |
72 | int errNo; ///< errno value from comm_open_sharedListen() call |
73 | int mapId; ///< to map future response to the requestor's callback | |
74 | }; | |
75 | ||
76 | /// prepare and send SharedListenRequest to Coordinator | |
82afb125 | 77 | void JoinSharedListen(const OpenListenerParams &, AsyncCall::Pointer &); |
0d0bce6a AR |
78 | |
79 | /// process Coordinator response to SharedListenRequest | |
82afb125 | 80 | void SharedListenJoined(const SharedListenResponse &response); |
0d0bce6a AR |
81 | |
82 | } // namespace Ipc; | |
83 | ||
0d0bce6a | 84 | #endif /* SQUID_IPC_SHARED_LISTEN_H */ |
f53969cc | 85 |