]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/Forwarder.h
81d68f4fa68fb20d7e4979cce1fe7f85bed1d8b8
[thirdparty/squid.git] / src / mgr / Forwarder.h
1 /*
2 * Copyright (C) 1996-2022 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 16 Cache Manager API */
10
11 #ifndef SQUID_MGR_FORWARDER_H
12 #define SQUID_MGR_FORWARDER_H
13
14 #include "comm/forward.h"
15 #include "ipc/Forwarder.h"
16 #include "log/forward.h"
17 #include "mgr/ActionParams.h"
18
19 class CommCloseCbParams;
20 class HttpRequest;
21 class StoreEntry;
22 class ErrorState;
23
24 namespace Mgr
25 {
26
27 /** Forwards a single client cache manager request to Coordinator.
28 * Waits for an ACK from Coordinator while holding the Store entry.
29 * Fills the store entry with an error response if forwarding fails.
30 */
31 class Forwarder: public Ipc::Forwarder
32 {
33 CBDATA_CHILD(Forwarder);
34
35 public:
36 Forwarder(const Comm::ConnectionPointer &aConn, const ActionParams &aParams, HttpRequest* aRequest,
37 StoreEntry* anEntry, const AccessLogEntryPointer &anAle);
38 ~Forwarder() override;
39
40 protected:
41 /* Ipc::Forwarder API */
42 void swanSong() override;
43 void handleError() override;
44 void handleTimeout() override;
45 void handleException(const std::exception& e) override;
46
47 private:
48 void noteCommClosed(const CommCloseCbParams& params);
49 void sendError(ErrorState* error);
50
51 private:
52 HttpRequest* httpRequest; ///< HTTP client request for detailing errors
53 StoreEntry* entry; ///< Store entry expecting the response
54 Comm::ConnectionPointer conn; ///< HTTP client connection descriptor
55 AsyncCall::Pointer closer; ///< comm_close handler for the HTTP connection
56 AccessLogEntryPointer ale; ///< more transaction details
57 };
58
59 } // namespace Mgr
60
61 #endif /* SQUID_MGR_FORWARDER_H */
62