Coordinator.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
26namespace Ipc
27{
28
30class Coordinator: public Port
31{
33
34public:
35 static Coordinator* Instance();
36
37public:
39
40 void broadcastSignal(int sig) const;
41
42 const StrandCoords &strands() const;
43
44protected:
45 void start() override; // Port (AsyncJob) API
46 void receive(const TypedMsgHdr& message) override; // Port API
47
48 StrandCoord* findStrand(int kidId);
49 void registerStrand(const StrandCoord &);
51
53 void notifySearcher(const StrandSearchRequest &request, const StrandCoord&);
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
68private:
70
71 typedef std::list<StrandSearchRequest> Searchers;
73
74 typedef std::map<OpenListenerParams, Comm::ConnectionPointer> Listeners;
76
78
79private:
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
Coordinates shared activities of Strands (Squid processes or threads)
Definition: Coordinator.h:31
StrandCoord * findStrand(int kidId)
registered strand or NULL
Definition: Coordinator.cc:44
std::map< OpenListenerParams, Comm::ConnectionPointer > Listeners
params:connection map
Definition: Coordinator.h:74
void handleSharedListenRequest(const SharedListenRequest &request)
returns cached socket or calls openListenSocket()
Definition: Coordinator.cc:147
Searchers searchers
yet unanswered search requests in arrival order
Definition: Coordinator.h:72
Listeners listeners
cached comm_open_listener() results
Definition: Coordinator.h:75
Comm::ConnectionPointer openListenSocket(const SharedListenRequest &request, int &errNo)
calls comm_open_listener()
Definition: Coordinator.cc:254
std::list< StrandSearchRequest > Searchers
search requests
Definition: Coordinator.h:71
void receive(const TypedMsgHdr &message) override
Definition: Coordinator.cc:79
Coordinator(const Coordinator &)
void handleSnmpRequest(const Snmp::Request &request)
Definition: Coordinator.cc:233
Coordinator & operator=(const Coordinator &)
static Coordinator * TheInstance
the only class instance in existence
Definition: Coordinator.h:77
const StrandCoords & strands() const
currently registered strands
Definition: Coordinator.cc:302
CBDATA_CHILD(Coordinator)
void handleCacheMgrRequest(const Mgr::Request &request)
Definition: Coordinator.cc:167
void notifySearcher(const StrandSearchRequest &request, const StrandCoord &)
answer the waiting search request
Definition: Coordinator.cc:220
void handleSnmpResponse(const Snmp::Response &response)
Definition: Coordinator.cc:246
void start() override
called by AsyncStart; do not call directly
Definition: Coordinator.cc:39
static Coordinator * Instance()
Definition: Coordinator.cc:291
void registerStrand(const StrandCoord &)
adds or updates existing
Definition: Coordinator.cc:54
void handleSearchRequest(const StrandSearchRequest &request)
answers or queues the request if the answer is not yet known
Definition: Coordinator.cc:199
void handleCacheMgrResponse(const Mgr::Response &response)
Definition: Coordinator.cc:193
void handleRegistrationRequest(const StrandMessage &)
register,ACK
Definition: Coordinator.cc:136
StrandCoords strands_
registered processes and threads
Definition: Coordinator.h:69
void broadcastSignal(int sig) const
send sig to registered strands
Definition: Coordinator.cc:281
Waits for and receives incoming IPC messages; kids handle the messages.
Definition: Port.h:22
a request for a listen socket with given parameters
Definition: SharedListen.h:47
Strand location details.
Definition: StrandCoord.h:22
an IPC message carrying StrandCoord
Definition: StrandCoord.h:39
asynchronous strand search request
Definition: StrandSearch.h:22
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
cache manager request
Definition: Request.h:24
SNMP request.
Definition: Request.h:25
Definition: IpcIoFile.h:24
std::vector< StrandCoord > StrandCoords
a collection of strand coordinates; the order, if any, is owner-dependent
Definition: StrandCoords.h:19

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors