]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/StoreToCommWriter.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / StoreToCommWriter.h
CommitLineData
8822ebee
AR
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"
c3e8e4e9 12#include "comm/forward.h"
8822ebee
AR
13#include "mgr/Action.h"
14#include "StoreIOBuffer.h"
15
8822ebee
AR
16class store_client;
17class CommIoCbParams;
18class CommCloseCbParams;
19
20namespace Mgr
21{
22
23/// manages receive-from-store, write-to-comm, receive-... sequence
24/// for the given StoreEntry and client FD
25class StoreToCommWriter: public AsyncJob
26{
27public:
c3e8e4e9 28 StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry *anEntry);
8822ebee
AR
29 virtual ~StoreToCommWriter();
30
31protected:
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
55protected:
c3e8e4e9 56 Comm::ConnectionPointer clientConnection; ///< HTTP client descriptor
8822ebee
AR
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
8822ebee
AR
68} // namespace Mgr
69
70#endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */