]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ipc/SharedListen.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / SharedListen.h
CommitLineData
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"
25b481e6 12#include "base/Subscription.h"
0d0bce6a
AR
13
14namespace Ipc
15{
16
17/// "shared listen" is when concurrent processes are listening on the same fd
18
e0d28505
AJ
19/// Comm::ConnAcceptor parameters holder
20/// all the details necessary to recreate a Comm::Connection and fde entry for the kid listener FD
0d0bce6a
AR
21class OpenListenerParams
22{
23public:
24 OpenListenerParams();
25
26 bool operator <(const OpenListenerParams &p) const; ///< useful for map<>
27
e0d28505 28 // bits to re-create the fde entry
0d0bce6a
AR
29 int sock_type;
30 int proto;
e0d28505
AJ
31 int fdNote; ///< index into fd_note() comment strings
32
33 // bits to re-create the listener Comm::Connection descriptor
a67d2b2e 34 Ip::Address addr; ///< will be memset and memcopied
0d0bce6a 35 int flags;
e0d28505
AJ
36
37 /// handler to subscribe to Comm::ConnAcceptor when we get the response
38 Subscription::Pointer handlerSubscription;
0d0bce6a
AR
39};
40
41class TypedMsgHdr;
42
43/// a request for a listen socket with given parameters
44class SharedListenRequest
45{
46public:
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()
50
51public:
52 int requestorId; ///< kidId of the requestor
53
54 OpenListenerParams params; ///< actual comm_open_sharedListen() parameters
55
56 int mapId; ///< to map future response to the requestor's callback
57};
58
59/// a response to SharedListenRequest
60class SharedListenResponse
61{
62public:
b72fb55d 63 SharedListenResponse(int fd, int errNo, int mapId);
0d0bce6a
AR
64 explicit SharedListenResponse(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
65 void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
66
67public:
b72fb55d 68 int fd; ///< opened listening socket or -1
0d0bce6a
AR
69 int errNo; ///< errno value from comm_open_sharedListen() call
70 int mapId; ///< to map future response to the requestor's callback
71};
72
73/// prepare and send SharedListenRequest to Coordinator
74extern void JoinSharedListen(const OpenListenerParams &, AsyncCall::Pointer &);
75
76/// process Coordinator response to SharedListenRequest
77extern void SharedListenJoined(const SharedListenResponse &response);
78
79} // namespace Ipc;
80
0d0bce6a 81#endif /* SQUID_IPC_SHARED_LISTEN_H */