2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 16 Cache Manager API */
11 #ifndef SQUID_MGR_STORE_TO_COMM_WRITER_H
12 #define SQUID_MGR_STORE_TO_COMM_WRITER_H
14 #include "base/AsyncJob.h"
15 #include "comm/forward.h"
16 #include "http/forward.h"
17 #include "mgr/Action.h"
18 #include "StoreIOBuffer.h"
22 class CommCloseCbParams
;
27 /// manages receive-from-store, write-to-comm, receive-... sequence
28 /// for the given StoreEntry and client FD
29 class StoreToCommWriter
: public AsyncJob
31 CBDATA_INTERMEDIATE();
34 StoreToCommWriter(const Comm::ConnectionPointer
&conn
, StoreEntry
*anEntry
);
35 ~StoreToCommWriter() override
;
39 void start() override
;
40 void swanSong() override
;
41 bool doneAll() const override
;
43 /// request more action results from the store
44 void scheduleStoreCopy();
45 /// receive some action results from the store
46 void noteStoreCopied(StoreIOBuffer ioBuf
);
47 static void NoteStoreCopied(void* data
, StoreIOBuffer ioBuf
);
48 /// called by Store if the entry is no longer usable
49 static void HandleStoreAbort(StoreToCommWriter
*param
);
51 /// tell Comm to write action results
52 void scheduleCommWrite(const StoreIOBuffer
& ioBuf
);
53 /// called by Comm after the action results are written
54 void noteCommWrote(const CommIoCbParams
& params
);
55 /// called by Comm if the client socket got closed
56 void noteCommClosed(const CommCloseCbParams
& params
);
58 /// closes the local connection to the HTTP client, if any
62 Comm::ConnectionPointer clientConnection
; ///< HTTP client descriptor
64 StoreEntry
* entry
; ///< store entry with the cache manager response
65 store_client
* sc
; ///< our registration with the store
66 int64_t writeOffset
; ///< number of bytes written to the client
68 AsyncCall::Pointer closer
; ///< comm_close handler
69 char buffer
[HTTP_REQBUF_SZ
]; ///< action results; Store fills, Comm writes
74 #endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */