]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Coordinator.h
Upgrade comm layer Connection handling
[thirdparty/squid.git] / src / ipc / Coordinator.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8 #ifndef SQUID_IPC_COORDINATOR_H
9 #define SQUID_IPC_COORDINATOR_H
10
11
12 #include "Array.h"
13 #include "ipc/Messages.h"
14 #include "ipc/Port.h"
15 #include "ipc/SharedListen.h"
16 #include "ipc/StrandCoords.h"
17 #include "mgr/forward.h"
18 #if SQUID_SNMP
19 #include "snmp/forward.h"
20 #endif
21 #include <map>
22
23 namespace Ipc
24 {
25
26 /// Coordinates shared activities of Strands (Squid processes or threads)
27 class Coordinator: public Port
28 {
29 public:
30 static Coordinator* Instance();
31
32 public:
33 Coordinator();
34
35 void broadcastSignal(int sig) const; ///< send sig to registered strands
36
37 const StrandCoords &strands() const; ///< currently registered strands
38
39 protected:
40 virtual void start(); // Port (AsyncJob) API
41 virtual void receive(const TypedMsgHdr& message); // Port API
42
43 StrandCoord* findStrand(int kidId); ///< registered strand or NULL
44 void registerStrand(const StrandCoord &); ///< adds or updates existing
45 void handleRegistrationRequest(const StrandCoord &); ///< register,ACK
46
47 /// returns cached socket or calls openListenSocket()
48 void handleSharedListenRequest(const SharedListenRequest& request);
49 void handleCacheMgrRequest(const Mgr::Request& request);
50 void handleCacheMgrResponse(const Mgr::Response& response);
51 #if SQUID_SNMP
52 void handleSnmpRequest(const Snmp::Request& request);
53 void handleSnmpResponse(const Snmp::Response& response);
54 #endif
55 /// calls comm_open_listener()
56 Comm::ConnectionPointer openListenSocket(const SharedListenRequest& request, int &errNo);
57
58 private:
59 StrandCoords strands_; ///< registered processes and threads
60
61 typedef std::map<OpenListenerParams, Comm::ConnectionPointer> Listeners; ///< params:fd map
62 Listeners listeners; ///< cached comm_open_listener() results
63
64 static Coordinator* TheInstance; ///< the only class instance in existence
65
66 private:
67 Coordinator(const Coordinator&); // not implemented
68 Coordinator& operator =(const Coordinator&); // not implemented
69
70 CBDATA_CLASS2(Coordinator);
71 };
72
73
74 } // namespace Ipc
75
76 #endif /* SQUID_IPC_COORDINATOR_H */