4 * DEBUG: section 54 Interprocess Communication
8 #ifndef SQUID_IPC_SHARED_LISTEN_H
9 #define SQUID_IPC_SHARED_LISTEN_H
11 #include "base/AsyncCall.h"
12 #include "base/Subscription.h"
17 /// "shared listen" is when concurrent processes are listening on the same fd
19 /// Comm::ConnAcceptor parameters holder
20 /// all the details necessary to recreate a Comm::Connection and fde entry for the kid listener FD
21 class OpenListenerParams
26 bool operator <(const OpenListenerParams
&p
) const; ///< useful for map<>
28 // bits to re-create the fde entry
31 int fdNote
; ///< index into fd_note() comment strings
33 // bits to re-create the listener Comm::Connection descriptor
34 Ip::Address addr
; ///< will be memset and memcopied
37 /// handler to subscribe to Comm::ConnAcceptor when we get the response
38 Subscription::Pointer handlerSubscription
;
43 /// a request for a listen socket with given parameters
44 class SharedListenRequest
47 SharedListenRequest(); ///< from OpenSharedListen() which then sets public data
48 explicit SharedListenRequest(const TypedMsgHdr
&hdrMsg
); ///< from recvmsg()
49 void pack(TypedMsgHdr
&hdrMsg
) const; ///< prepare for sendmsg()
52 int requestorId
; ///< kidId of the requestor
54 OpenListenerParams params
; ///< actual comm_open_sharedListen() parameters
56 int mapId
; ///< to map future response to the requestor's callback
59 /// a response to SharedListenRequest
60 class SharedListenResponse
63 SharedListenResponse(int fd
, int errNo
, int mapId
);
64 explicit SharedListenResponse(const TypedMsgHdr
&hdrMsg
); ///< from recvmsg()
65 void pack(TypedMsgHdr
&hdrMsg
) const; ///< prepare for sendmsg()
68 int fd
; ///< opened listening socket or -1
69 int errNo
; ///< errno value from comm_open_sharedListen() call
70 int mapId
; ///< to map future response to the requestor's callback
73 /// prepare and send SharedListenRequest to Coordinator
74 extern void JoinSharedListen(const OpenListenerParams
&, AsyncCall::Pointer
&);
76 /// process Coordinator response to SharedListenRequest
77 extern void SharedListenJoined(const SharedListenResponse
&response
);
81 #endif /* SQUID_IPC_SHARED_LISTEN_H */