2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 54 Interprocess Communication */
11 #ifndef SQUID_IPC_SHARED_LISTEN_H
12 #define SQUID_IPC_SHARED_LISTEN_H
14 #include "base/AsyncCall.h"
15 #include "base/Subscription.h"
20 /// "shared listen" is when concurrent processes are listening on the same fd
22 /// Comm::ConnAcceptor parameters holder
23 /// all the details necessary to recreate a Comm::Connection and fde entry for the kid listener FD
24 class OpenListenerParams
29 bool operator <(const OpenListenerParams
&p
) const; ///< useful for map<>
31 // bits to re-create the fde entry
34 int fdNote
; ///< index into fd_note() comment strings
36 // bits to re-create the listener Comm::Connection descriptor
37 Ip::Address addr
; ///< will be memset and memcopied
40 /// handler to subscribe to Comm::ConnAcceptor when we get the response
41 Subscription::Pointer handlerSubscription
;
46 /// a request for a listen socket with given parameters
47 class SharedListenRequest
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()
55 int requestorId
; ///< kidId of the requestor
57 OpenListenerParams params
; ///< actual comm_open_sharedListen() parameters
59 int mapId
; ///< to map future response to the requestor's callback
62 /// a response to SharedListenRequest
63 class SharedListenResponse
66 SharedListenResponse(int fd
, int errNo
, int mapId
);
67 explicit SharedListenResponse(const TypedMsgHdr
&hdrMsg
); ///< from recvmsg()
68 void pack(TypedMsgHdr
&hdrMsg
) const; ///< prepare for sendmsg()
71 int fd
; ///< opened listening socket or -1
72 int errNo
; ///< errno value from comm_open_sharedListen() call
73 int mapId
; ///< to map future response to the requestor's callback
76 /// prepare and send SharedListenRequest to Coordinator
77 void JoinSharedListen(const OpenListenerParams
&, AsyncCall::Pointer
&);
79 /// process Coordinator response to SharedListenRequest
80 void SharedListenJoined(const SharedListenResponse
&response
);
84 #endif /* SQUID_IPC_SHARED_LISTEN_H */