RockHeaderUpdater.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 #ifndef SQUID_SRC_FS_ROCK_ROCKHEADERUPDATER_H
10 #define SQUID_SRC_FS_ROCK_ROCKHEADERUPDATER_H
11 
12 #include "base/AsyncJob.h"
13 #include "cbdata.h"
14 #include "fs/rock/forward.h"
15 #include "fs/rock/RockSwapDir.h"
16 #include "ipc/StoreMap.h"
17 
18 namespace Rock
19 {
20 
26 class HeaderUpdater: public AsyncJob
27 {
29 
30 public:
31  class IoCbParams {
32  public:
33  IoCbParams(const char *aBuf, ssize_t aSize) : buf(aBuf), size(aSize) {}
34  const char *buf;
35  ssize_t size;
36  };
38  ~HeaderUpdater() override = default;
39 
40 protected:
41  /* AsyncJob API */
42  void start() override;
43  bool doneAll() const override;
44  void swanSong() override;
45 
46 private:
50 
51  void startReading();
52  void stopReading(const char *why);
53  void readMore(const char *why);
54  void noteRead(const IoCbParams result);
55  void noteDoneReading(int errflag);
56  void parseReadBytes();
57 
58  void startWriting();
59  void noteDoneWriting(int errflag);
60 
63 
66 
69  uint64_t bytesRead;
70 
72 
74 };
75 
76 inline
77 std::ostream &operator <<(std::ostream &os, const HeaderUpdater::IoCbParams &params)
78 {
79  os << static_cast<const void *>(params.buf) << "," << params.size;
80  return os;
81 }
82 
83 } // namespace Rock
84 
85 #endif /* SQUID_SRC_FS_ROCK_ROCKHEADERUPDATER_H */
86 
size_t staleSwapHeaderSize
stored size of the stale entry metadata
SlotId staleSplicingPointNext
non-updatable old HTTP body suffix start
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
Definition: forward.h:27
~HeaderUpdater() override=default
Definition: SBuf.h:93
void noteDoneWriting(int errflag)
SBuf exchangeBuffer
bytes read but not yet discarded or written
bool doneAll() const override
whether positive goal has been reached
CBDATA_CHILD(HeaderUpdater)
std::ostream & operator<<(std::ostream &os, const HeaderUpdater::IoCbParams &params)
static StoreIOState::STIOCB NoteDoneReading
SBuf readerBuffer
I/O buffer for a single read operation.
StoreIOState::Pointer writer
writes new headers and old data
void swanSong() override
void noteRead(const IoCbParams result)
StoreIOState::Pointer reader
reads old headers and old data
uint64_t bytesRead
total entry bytes read from Store so far
void noteDoneReading(int errflag)
void stopReading(const char *why)
void readMore(const char *why)
Aggregates information required for updating entry metadata and headers.
Definition: StoreMap.h:181
static StoreIOState::STRCB NoteRead
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
sfileno SlotId
db cell number, starting with cell 0 (always occupied by the db header)
Definition: forward.h:30
HeaderUpdater(const Rock::SwapDir::Pointer &aStore, const Ipc::StoreMapUpdate &update)
Rock::SwapDir::Pointer store
cache_dir where the entry is stored
IoCbParams(const char *aBuf, ssize_t aSize)
void start() override
called by AsyncStart; do not call directly
static StoreIOState::STIOCB NoteDoneWriting
Ipc::StoreMapUpdate update
Ipc::StoreMap update reservation.

 

Introduction

Documentation

Support

Miscellaneous