2 * Copyright (C) 1996-2020 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 "mgr/Action.h"
17 #include "StoreIOBuffer.h"
21 class CommCloseCbParams
;
26 /// manages receive-from-store, write-to-comm, receive-... sequence
27 /// for the given StoreEntry and client FD
28 class StoreToCommWriter
: public AsyncJob
30 CBDATA_CLASS(StoreToCommWriter
);
33 StoreToCommWriter(const Comm::ConnectionPointer
&conn
, StoreEntry
*anEntry
);
34 virtual ~StoreToCommWriter();
39 virtual void swanSong();
40 virtual bool doneAll() const;
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
);
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
);
57 /// closes the local connection to the HTTP client, if any
61 Comm::ConnectionPointer clientConnection
; ///< HTTP client descriptor
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
67 AsyncCall::Pointer closer
; ///< comm_close handler
68 char buffer
[HTTP_REQBUF_SZ
]; ///< action results; Store fills, Comm writes
73 #endif /* SQUID_MGR_STORE_TO_COMM_WRITER_H */