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