]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/Forwarder.h
Debug display the latest orphan Comm::Connection
[thirdparty/squid.git] / src / mgr / Forwarder.h
CommitLineData
8822ebee
AR
1/*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8#ifndef SQUID_MGR_FORWARDER_H
9#define SQUID_MGR_FORWARDER_H
10
11#include "base/AsyncJob.h"
12#include "mgr/ActionParams.h"
13#include <map>
14
15
16class CommCloseCbParams;
17class HttpRequest;
18class StoreEntry;
19class ErrorState;
20
21namespace Mgr
22{
23
24/** Forwards a single client cache manager request to Coordinator.
25 * Waits for an ACK from Coordinator while holding the Store entry.
26 * Fills the store entry with an error response if forwarding fails.
27 */
28class Forwarder: public AsyncJob
29{
30public:
31 Forwarder(int aFd, const ActionParams &aParams, HttpRequest* aRequest,
d9fc6862 32 StoreEntry* anEntry);
8822ebee
AR
33 virtual ~Forwarder();
34
35 /// finds and calls the right Forwarder upon Coordinator's response
36 static void HandleRemoteAck(unsigned int requestId);
37
38 /* has-to-be-public AsyncJob API */
39 virtual void callException(const std::exception& e);
40
41protected:
42 /* AsyncJob API */
43 virtual void start();
44 virtual void swanSong();
45 virtual bool doneAll() const;
46
47private:
48 void handleRemoteAck();
49 static void RequestTimedOut(void* param);
50 void requestTimedOut();
51 void quitOnError(const char *reason, ErrorState *error);
52 void noteCommClosed(const CommCloseCbParams& params);
53 void removeTimeoutEvent();
54 static AsyncCall::Pointer DequeueRequest(unsigned int requestId);
55 static void Abort(void* param);
56 void close();
57
58private:
59 ActionParams params; ///< action parameters to pass to the other side
60 HttpRequest* request; ///< HTTP client request for detailing errors
61 StoreEntry* entry; ///< Store entry expecting the response
62 int fd; ///< HTTP client connection descriptor
63 unsigned int requestId; ///< request id
64 AsyncCall::Pointer closer; ///< comm_close handler for the HTTP connection
65
66 /// maps requestId to Forwarder::handleRemoteAck callback
67 typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap;
68 static RequestsMap TheRequestsMap; ///< pending Coordinator requests
69
70 static unsigned int LastRequestId; ///< last requestId used
71
72 CBDATA_CLASS2(Forwarder);
73};
74
75} // namespace Mgr
76
77#endif /* SQUID_MGR_FORWARDER_H */