]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/StoreToCommWriter.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / mgr / StoreToCommWriter.h
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 16 Cache Manager API */
10
11 #ifndef SQUID_MGR_STORE_TO_COMM_WRITER_H
12 #define SQUID_MGR_STORE_TO_COMM_WRITER_H
13
14 #include "base/AsyncJob.h"
15 #include "comm/forward.h"
16 #include "http/forward.h"
17 #include "mgr/Action.h"
18 #include "StoreIOBuffer.h"
19
20 class store_client;
21 class CommIoCbParams;
22 class CommCloseCbParams;
23
24 namespace Mgr
25 {
26
27 /// manages receive-from-store, write-to-comm, receive-... sequence
28 /// for the given StoreEntry and client FD
29 class StoreToCommWriter: public AsyncJob
30 {
31 CBDATA_INTERMEDIATE();
32
33 public:
34 StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry *anEntry);
35 ~StoreToCommWriter() override;
36
37 protected:
38 /* AsyncJob API */
39 void start() override;
40 void swanSong() override;
41 bool doneAll() const override;
42
43 /// request more action results from the store
44 void scheduleStoreCopy();
45 /// receive some action results from the store
46 void noteStoreCopied(StoreIOBuffer ioBuf);
47 static void NoteStoreCopied(void* data, StoreIOBuffer ioBuf);
48 /// called by Store if the entry is no longer usable
49 static void HandleStoreAbort(StoreToCommWriter *param);
50
51 /// tell Comm to write action results
52 void scheduleCommWrite(const StoreIOBuffer& ioBuf);
53 /// called by Comm after the action results are written
54 void noteCommWrote(const CommIoCbParams& params);
55 /// called by Comm if the client socket got closed
56 void noteCommClosed(const CommCloseCbParams& params);
57
58 /// closes the local connection to the HTTP client, if any
59 void close();
60
61 protected:
62 Comm::ConnectionPointer clientConnection; ///< HTTP client descriptor
63
64 StoreEntry* entry; ///< store entry with the cache manager response
65 store_client* sc; ///< our registration with the store
66 int64_t writeOffset; ///< number of bytes written to the client
67
68 AsyncCall::Pointer closer; ///< comm_close handler
69 char buffer[HTTP_REQBUF_SZ]; ///< action results; Store fills, Comm writes
70 };
71
72 } // namespace Mgr
73
74 #endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */
75