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