StoreIOState.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_STOREIOSTATE_H
10 #define SQUID_SRC_STOREIOSTATE_H
11 
12 #include "base/RefCount.h"
13 #include "cbdata.h"
14 #include "mem/forward.h"
15 #include "store/forward.h"
16 
17 class StoreIOState : public RefCountable
18 {
19 
20 public:
22 
23  /*
24  * STRCB is the "store read callback". STRCB functions are
25  * passed to storeRead(). Examples of STRCB callbacks are:
26  * storeClientReadBody
27  * storeClientReadHeader
28  */
29  typedef void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self);
30 
31  /*
32  * STIOCB is the "store close callback" for store files. It
33  * is called when the store file is closed. STIOCB functions
34  * are passed to storeCreate() and storeOpen(). Examples of
35  * STIOCB callbacks are:
36  * storeSwapOutFileClosed
37  * storeSwapInFileClosed
38  */
39  typedef void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self);
40 
41  /* StoreIOState does not get mempooled - it's children do */
42  void *operator new (size_t amount);
43  void operator delete (void *address);
44 
45  StoreIOState(StoreIOState::STIOCB *, void *cbData);
46  ~StoreIOState() override;
47 
48  off_t offset() const {return offset_;}
49 
50  virtual void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) = 0;
55  virtual bool write(char const *buf, size_t size, off_t offset, FREE * free_func) = 0;
56 
57  typedef enum {
61  } CloseHow;
62  virtual void close(int how) = 0;
63 
64  // Tests whether we are working with the primary/public StoreEntry chain.
65  // Reads start reading the primary chain, but it may become secondary.
66  // There are two store write kinds:
67  // * regular writes that change (usually append) the entry visible to all and
68  // * header updates that create a fresh chain (while keeping the stale one usable).
69  bool touchingStoreEntry() const;
70 
73  StoreEntry *e; /* Need this so the FS layers can play god */
75  off_t offset_;
78 
79  struct {
81  void *callback_data;
82  } read;
83 
84  struct {
85  bool closing; /* debugging aid */
86  } flags;
87 };
88 
91 void storeClose(StoreIOState::Pointer, int how);
92 void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *);
93 void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
94 
95 #endif /* SQUID_SRC_STOREIOSTATE_H */
96 
STRCB * callback
Definition: StoreIOState.h:80
void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *)
Definition: store_io.cc:79
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
StoreIOState::Pointer storeCreate(StoreEntry *, StoreIOState::STIOCB *, void *)
Definition: store_io.cc:25
RefCount< StoreIOState > Pointer
Definition: StoreIOState.h:21
void FREE(void *)
Definition: forward.h:37
void storeClose(StoreIOState::Pointer, int how)
Definition: store_io.cc:65
void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *)
Definition: store_io.cc:85
bool touchingStoreEntry() const
Definition: StoreIOState.cc:52
@ wroteAll
success: caller supplied all data it wanted to swap out
Definition: StoreIOState.h:58
@ readerDone
success or failure: either way, stop swapping in
Definition: StoreIOState.h:60
virtual void close(int how)=0
finish or abort swapping per CloseHow
int size
Definition: ModDevPoll.cc:69
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)=0
off_t offset() const
Definition: StoreIOState.h:48
signed_int32_t sfileno
Definition: forward.h:22
signed int sdirno
Definition: forward.h:23
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
struct StoreIOState::@131 read
virtual bool write(char const *buf, size_t size, off_t offset, FREE *free_func)=0
unsigned short mode_t
Definition: types.h:129
StoreEntry * e
Definition: StoreIOState.h:73
STIOCB * callback
Definition: StoreIOState.h:76
void * callback_data
Definition: StoreIOState.h:77
sdirno swap_dirn
Definition: StoreIOState.h:71
@ writerGone
failure: caller left before swapping out everything
Definition: StoreIOState.h:59
StoreIOState(StoreIOState::STIOCB *, void *cbData)
Definition: StoreIOState.cc:30
off_t offset_
number of bytes written or read for this entry so far
Definition: StoreIOState.h:75
sfileno swap_filen
Definition: StoreIOState.h:72
StoreIOState::Pointer storeOpen(StoreEntry *, StoreIOState::STIOCB *, void *)
Definition: store_io.cc:58
~StoreIOState() override
Definition: StoreIOState.cc:44
struct StoreIOState::@132 flags

 

Introduction

Documentation

Support

Miscellaneous