]>
Commit | Line | Data |
---|---|---|
0d0bce6a AR |
1 | /* |
2 | * $Id$ | |
3 | * | |
4 | * DEBUG: section 54 Interprocess Communication | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef SQUID_IPC_SHARED_LISTEN_H | |
9 | #define SQUID_IPC_SHARED_LISTEN_H | |
10 | ||
11 | #include "base/AsyncCall.h" | |
12 | ||
13 | namespace Ipc | |
14 | { | |
15 | ||
16 | /// "shared listen" is when concurrent processes are listening on the same fd | |
17 | ||
18 | /// comm_open_listener() parameters holder | |
19 | class OpenListenerParams | |
20 | { | |
21 | public: | |
22 | OpenListenerParams(); | |
23 | ||
24 | bool operator <(const OpenListenerParams &p) const; ///< useful for map<> | |
25 | ||
26 | int sock_type; | |
27 | int proto; | |
a67d2b2e | 28 | Ip::Address addr; ///< will be memset and memcopied |
0d0bce6a AR |
29 | int flags; |
30 | int fdNote; ///< index into fd_note() comment strings | |
31 | }; | |
32 | ||
33 | class TypedMsgHdr; | |
34 | ||
35 | /// a request for a listen socket with given parameters | |
36 | class SharedListenRequest | |
37 | { | |
38 | public: | |
39 | SharedListenRequest(); ///< from OpenSharedListen() which then sets public data | |
40 | explicit SharedListenRequest(const TypedMsgHdr &hdrMsg); ///< from recvmsg() | |
41 | void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() | |
42 | ||
43 | public: | |
44 | int requestorId; ///< kidId of the requestor | |
45 | ||
46 | OpenListenerParams params; ///< actual comm_open_sharedListen() parameters | |
47 | ||
48 | int mapId; ///< to map future response to the requestor's callback | |
49 | }; | |
50 | ||
51 | /// a response to SharedListenRequest | |
52 | class SharedListenResponse | |
53 | { | |
54 | public: | |
55 | SharedListenResponse(int fd, int errNo, int mapId); | |
56 | explicit SharedListenResponse(const TypedMsgHdr &hdrMsg); ///< from recvmsg() | |
57 | void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg() | |
58 | ||
59 | public: | |
60 | int fd; ///< opened listening socket or -1 | |
61 | int errNo; ///< errno value from comm_open_sharedListen() call | |
62 | int mapId; ///< to map future response to the requestor's callback | |
63 | }; | |
64 | ||
65 | /// prepare and send SharedListenRequest to Coordinator | |
66 | extern void JoinSharedListen(const OpenListenerParams &, AsyncCall::Pointer &); | |
67 | ||
68 | /// process Coordinator response to SharedListenRequest | |
69 | extern void SharedListenJoined(const SharedListenResponse &response); | |
70 | ||
71 | } // namespace Ipc; | |
72 | ||
73 | ||
74 | #endif /* SQUID_IPC_SHARED_LISTEN_H */ |