]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/StoreToCommWriter.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / mgr / StoreToCommWriter.h
CommitLineData
8822ebee 1/*
f70aedc4 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
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.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
8822ebee
AR
11#ifndef SQUID_MGR_STORE_TO_COMM_WRITER_H
12#define SQUID_MGR_STORE_TO_COMM_WRITER_H
13
14#include "base/AsyncJob.h"
c3e8e4e9 15#include "comm/forward.h"
8822ebee
AR
16#include "mgr/Action.h"
17#include "StoreIOBuffer.h"
18
8822ebee
AR
19class store_client;
20class CommIoCbParams;
21class CommCloseCbParams;
22
23namespace Mgr
24{
25
26/// manages receive-from-store, write-to-comm, receive-... sequence
27/// for the given StoreEntry and client FD
28class StoreToCommWriter: public AsyncJob
29{
5c2f68b7
AJ
30 CBDATA_CLASS(StoreToCommWriter);
31
8822ebee 32public:
c3e8e4e9 33 StoreToCommWriter(const Comm::ConnectionPointer &conn, StoreEntry *anEntry);
8822ebee
AR
34 virtual ~StoreToCommWriter();
35
36protected:
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
7e9f330d 48 static void HandleStoreAbort(StoreToCommWriter *param);
8822ebee
AR
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
60protected:
c3e8e4e9 61 Comm::ConnectionPointer clientConnection; ///< HTTP client descriptor
8822ebee
AR
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
8822ebee
AR
69};
70
8822ebee
AR
71} // namespace Mgr
72
73#endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */
f53969cc 74