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