]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/Inquirer.h
Add some stubs and undo some problematic make optimizations
[thirdparty/squid.git] / src / mgr / Inquirer.h
CommitLineData
8822ebee
AR
1/*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8#ifndef SQUID_MGR_INQUIRER_H
9#define SQUID_MGR_INQUIRER_H
10
11#include "base/AsyncJobCalls.h"
12#include "base/AsyncJob.h"
c3e8e4e9 13#include "comm/forward.h"
8822ebee
AR
14#include "ipc/StrandCoords.h"
15#include "MemBuf.h"
16#include "mgr/Action.h"
17#include "mgr/Request.h"
18#include <map>
19
20class CommIoCbParams;
21class CommCloseCbParams;
22
23namespace Mgr
24{
25
26/// Coordinator's job that sends a cache manage request to each strand,
27/// aggregating individual strand responses and dumping the result if needed
28class Inquirer: public AsyncJob
29{
30public:
c3e8e4e9 31 Inquirer(Action::Pointer anAction, const Comm::ConnectionPointer &conn, const Request &aCause,
d9fc6862 32 const Ipc::StrandCoords &coords);
8822ebee
AR
33 virtual ~Inquirer();
34
35 /// finds and calls the right Inquirer upon strand's response
36 static void HandleRemoteAck(const Mgr::Response& response);
37
38protected:
39 /* AsyncJob API */
40 virtual void start();
41 virtual void swanSong();
42 virtual bool doneAll() const;
43 virtual const char *status() const;
44
45private:
46 typedef UnaryMemFunT<Inquirer, Response, const Response&> HandleAckDialer;
47
48 void inquire();
49 void noteWroteHeader(const CommIoCbParams& params);
50 void noteCommClosed(const CommCloseCbParams& params);
51
52 void handleRemoteAck(const Response& response);
53
54 static AsyncCall::Pointer DequeueRequest(unsigned int requestId);
55
56 static void RequestTimedOut(void* param);
57 void requestTimedOut();
58 void removeTimeoutEvent();
59
60 void close();
61 void removeCloseHandler();
62
63private:
64 Action::Pointer aggrAction; //< action to aggregate
65
66 Request cause; ///< cache manager request received from HTTP client
c3e8e4e9 67 Comm::ConnectionPointer clientConnection; ///< HTTP client socket descriptor
8822ebee
AR
68
69 Ipc::StrandCoords strands; ///< all strands we want to query, in order
70 Ipc::StrandCoords::const_iterator pos; ///< strand we should query now
71
72 unsigned int requestId; ///< ID of our outstanding request to strand
73 AsyncCall::Pointer writer; ///< comm_write callback
74 AsyncCall::Pointer closer; ///< comm_close handler
75 const double timeout; ///< number of seconds to wait for strand response
76
77 /// maps requestId to Inquirer::handleRemoteAck callback
78 typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap;
79 static RequestsMap TheRequestsMap; ///< pending strand requests
80
81 static unsigned int LastRequestId; ///< last requestId used
82
83 CBDATA_CLASS2(Inquirer);
84};
85
86} // namespace Mgr
87
88#endif /* SQUID_MGR_INQUIRER_H */