]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Coordinator.h
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_COORDINATOR_H
12 #define SQUID_IPC_COORDINATOR_H
14 #include "ipc/Messages.h"
16 #include "ipc/SharedListen.h"
17 #include "ipc/StrandCoords.h"
18 #include "ipc/StrandSearch.h"
19 #include "mgr/forward.h"
21 #include "snmp/forward.h"
29 /// Coordinates shared activities of Strands (Squid processes or threads)
30 class Coordinator
: public Port
32 CBDATA_CLASS(Coordinator
);
35 static Coordinator
* Instance();
40 void broadcastSignal(int sig
) const; ///< send sig to registered strands
42 const StrandCoords
&strands() const; ///< currently registered strands
45 virtual void start(); // Port (AsyncJob) API
46 virtual void receive(const TypedMsgHdr
& message
); // Port API
48 StrandCoord
* findStrand(int kidId
); ///< registered strand or NULL
49 void registerStrand(const StrandCoord
&); ///< adds or updates existing
50 void handleRegistrationRequest(const HereIamMessage
&); ///< register,ACK
52 /// answer the waiting search request
53 void notifySearcher(const StrandSearchRequest
&request
, const StrandCoord
&);
54 /// answers or queues the request if the answer is not yet known
55 void handleSearchRequest(const StrandSearchRequest
&request
);
57 /// returns cached socket or calls openListenSocket()
58 void handleSharedListenRequest(const SharedListenRequest
& request
);
59 void handleCacheMgrRequest(const Mgr::Request
& request
);
60 void handleCacheMgrResponse(const Mgr::Response
& response
);
62 void handleSnmpRequest(const Snmp::Request
& request
);
63 void handleSnmpResponse(const Snmp::Response
& response
);
65 /// calls comm_open_listener()
66 Comm::ConnectionPointer
openListenSocket(const SharedListenRequest
& request
, int &errNo
);
69 StrandCoords strands_
; ///< registered processes and threads
71 typedef std::list
<StrandSearchRequest
> Searchers
; ///< search requests
72 Searchers searchers
; ///< yet unanswered search requests in arrival order
74 typedef std::map
<OpenListenerParams
, Comm::ConnectionPointer
> Listeners
; ///< params:connection map
75 Listeners listeners
; ///< cached comm_open_listener() results
77 static Coordinator
* TheInstance
; ///< the only class instance in existence
80 Coordinator(const Coordinator
&); // not implemented
81 Coordinator
& operator =(const Coordinator
&); // not implemented
86 #endif /* SQUID_IPC_COORDINATOR_H */