Coordinator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 /* DEBUG: section 54 Interprocess Communication */
10 
11 #ifndef SQUID_IPC_COORDINATOR_H
12 #define SQUID_IPC_COORDINATOR_H
13 
14 #include "ipc/Messages.h"
15 #include "ipc/Port.h"
16 #include "ipc/SharedListen.h"
17 #include "ipc/StrandCoords.h"
18 #include "ipc/StrandSearch.h"
19 #include "mgr/forward.h"
20 #if SQUID_SNMP
21 #include "snmp/forward.h"
22 #endif
23 #include <list>
24 #include <map>
25 
26 namespace Ipc
27 {
28 
30 class Coordinator: public Port
31 {
33 
34 public:
35  static Coordinator* Instance();
36 
37 public:
38  Coordinator();
39 
40  void broadcastSignal(int sig) const;
41 
42  const StrandCoords &strands() const;
43 
44 protected:
45  virtual void start(); // Port (AsyncJob) API
46  virtual void receive(const TypedMsgHdr& message); // Port API
47 
48  StrandCoord* findStrand(int kidId);
49  void registerStrand(const StrandCoord &);
51 
55  void handleSearchRequest(const StrandSearchRequest &request);
56 
59  void handleCacheMgrRequest(const Mgr::Request& request);
60  void handleCacheMgrResponse(const Mgr::Response& response);
61 #if SQUID_SNMP
62  void handleSnmpRequest(const Snmp::Request& request);
63  void handleSnmpResponse(const Snmp::Response& response);
64 #endif
67 
68 private:
70 
71  typedef std::list<StrandSearchRequest> Searchers;
73 
74  typedef std::map<OpenListenerParams, Comm::ConnectionPointer> Listeners;
76 
78 
79 private:
80  Coordinator(const Coordinator&); // not implemented
81  Coordinator& operator =(const Coordinator&); // not implemented
82 };
83 
84 } // namespace Ipc
85 
86 #endif /* SQUID_IPC_COORDINATOR_H */
87 
Coordinator & operator=(const Coordinator &)
strand registration with Coordinator (also used as an ACK)
Definition: StrandCoord.h:36
cache manager request
Definition: Request.h:22
Coordinates shared activities of Strands (Squid processes or threads)
Definition: Coordinator.h:30
void handleSnmpRequest(const Snmp::Request &request)
Definition: Coordinator.cc:233
Strand location details.
Definition: StrandCoord.h:19
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void handleRegistrationRequest(const HereIamMessage &)
register,ACK
Definition: Coordinator.cc:136
asynchronous strand search request
Definition: StrandSearch.h:20
std::list< StrandSearchRequest > Searchers
search requests
Definition: Coordinator.h:71
void notifySearcher(const StrandSearchRequest &request, const StrandCoord &)
answer the waiting search request
Definition: Coordinator.cc:220
void handleCacheMgrRequest(const Mgr::Request &request)
Definition: Coordinator.cc:167
Listeners listeners
cached comm_open_listener() results
Definition: Coordinator.h:75
StrandCoords strands_
registered processes and threads
Definition: Coordinator.h:69
static Coordinator * TheInstance
the only class instance in existence
Definition: Coordinator.h:77
a request for a listen socket with given parameters
Definition: SharedListen.h:47
std::vector< StrandCoord > StrandCoords
a collection of strand coordinates; the order, if any, is owner-dependent
Definition: StrandCoords.h:19
SNMP request.
Definition: Request.h:24
void handleCacheMgrResponse(const Mgr::Response &response)
Definition: Coordinator.cc:193
void handleSnmpResponse(const Snmp::Response &response)
Definition: Coordinator.cc:246
virtual void receive(const TypedMsgHdr &message)
handle IPC message just read
Definition: Coordinator.cc:79
StrandCoord * findStrand(int kidId)
registered strand or NULL
Definition: Coordinator.cc:44
virtual void start()
called by AsyncStart; do not call directly
Definition: Coordinator.cc:39
Waits for and receives incoming IPC messages; kids handle the messages.
Definition: Port.h:21
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:31
Searchers searchers
yet unanswered search requests in arrival order
Definition: Coordinator.h:72
const StrandCoords & strands() const
currently registered strands
Definition: Coordinator.cc:302
Comm::ConnectionPointer openListenSocket(const SharedListenRequest &request, int &errNo)
calls comm_open_listener()
Definition: Coordinator.cc:254
void registerStrand(const StrandCoord &)
adds or updates existing
Definition: Coordinator.cc:54
static Coordinator * Instance()
Definition: Coordinator.cc:291
CBDATA_CLASS(Coordinator)
void handleSharedListenRequest(const SharedListenRequest &request)
returns cached socket or calls openListenSocket()
Definition: Coordinator.cc:147
std::map< OpenListenerParams, Comm::ConnectionPointer > Listeners
params:connection map
Definition: Coordinator.h:74
void broadcastSignal(int sig) const
send sig to registered strands
Definition: Coordinator.cc:281
void handleSearchRequest(const StrandSearchRequest &request)
answers or queues the request if the answer is not yet known
Definition: Coordinator.cc:199

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors