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