StoreIOState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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_STOREIOSTATE_H
10 #define SQUID_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  * STFNCB is the "store file number callback." It is called
33  * when an underlying storage module has allocated the swap
34  * file number and also indicates that the swap file has been
35  * opened for reading or writing. STFNCB functions are passed
36  * to storeCreate() and storeOpen(). Examples of STFNCB callbacks
37  * are:
38  * storeSwapInFileNotify
39  * storeSwapOutFileNotify
40  */
41  typedef void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self);
42 
43  /*
44  * STIOCB is the "store close callback" for store files. It
45  * is called when the store file is closed. STIOCB functions
46  * are passed to storeCreate() and storeOpen(). Examples of
47  * STIOCB callbacks are:
48  * storeSwapOutFileClosed
49  * storeSwapInFileClosed
50  */
51  typedef void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self);
52 
53  /* StoreIOState does not get mempooled - it's children do */
54  void *operator new (size_t amount);
55  void operator delete (void *address);
56 
58  virtual ~StoreIOState();
59 
60  off_t offset() const {return offset_;}
61 
62  virtual void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data) = 0;
67  virtual bool write(char const *buf, size_t size, off_t offset, FREE * free_func) = 0;
68 
69  typedef enum {
73  } CloseHow;
74  virtual void close(int how) = 0;
75 
76  // Tests whether we are working with the primary/public StoreEntry chain.
77  // Reads start reading the primary chain, but it may become secondary.
78  // There are two store write kinds:
79  // * regular writes that change (usually append) the entry visible to all and
80  // * header updates that create a fresh chain (while keeping the stale one usable).
81  bool touchingStoreEntry() const;
82 
85  StoreEntry *e; /* Need this so the FS layers can play god */
87  off_t offset_;
88  STFNCB *file_callback; // XXX: Unused. TODO: Remove.
91 
92  struct {
94  void *callback_data;
95  } read;
96 
97  struct {
98  bool closing; /* debugging aid */
99  } flags;
100 };
101 
104 void storeClose(StoreIOState::Pointer, int how);
105 void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *);
106 void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
107 
108 #endif /* SQUID_STOREIOSTATE_H */
109 
StoreIOState(StoreIOState::STFNCB *cbFile, StoreIOState::STIOCB *cbIo, void *data)
Definition: StoreIOState.cc:30
RefCount< StoreIOState > Pointer
Definition: StoreIOState.h:21
virtual ~StoreIOState()
Definition: StoreIOState.cc:45
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
void storeClose(StoreIOState::Pointer sio, int how)
Definition: store_io.cc:68
bool touchingStoreEntry() const
Definition: StoreIOState.cc:56
off_t offset() const
Definition: StoreIOState.h:60
void FREE(void *)
Definition: forward.h:36
void storeIOWrite(StoreIOState::Pointer sio, char const *buf, size_t size, off_t offset, FREE *free_func)
Definition: store_io.cc:88
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)=0
void const char HLPCB void * data
Definition: stub_helper.cc:16
STFNCB * file_callback
Definition: StoreIOState.h:88
success: caller supplied all data it wanted to swap out
Definition: StoreIOState.h:70
success or failure: either way, stop swapping in
Definition: StoreIOState.h:72
virtual void close(int how)=0
finish or abort swapping per CloseHow
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
struct StoreIOState::@148 flags
signed_int32_t sfileno
Definition: forward.h:22
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
void const char * buf
Definition: stub_helper.cc:16
unsigned short mode_t
Definition: types.h:150
signed int sdirno
Definition: forward.h:23
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
StoreIOState::Pointer storeOpen(StoreEntry *e, StoreIOState::STFNCB *file_callback, StoreIOState::STIOCB *callback, void *callback_data)
Definition: store_io.cc:61
struct StoreIOState::@147 read
virtual bool write(char const *buf, size_t size, off_t offset, FREE *free_func)=0
StoreEntry * e
Definition: StoreIOState.h:85
STIOCB * callback
Definition: StoreIOState.h:89
sdirno swap_dirn
Definition: StoreIOState.h:83
failure: caller left before swapping out everything
Definition: StoreIOState.h:71
off_t offset_
number of bytes written or read for this entry so far
Definition: StoreIOState.h:87
void * callback_data
Definition: StoreIOState.h:90
StoreIOState::Pointer storeCreate(StoreEntry *e, StoreIOState::STFNCB *file_callback, StoreIOState::STIOCB *close_callback, void *callback_data)
Definition: store_io.cc:25
int size
Definition: ModDevPoll.cc:77
STRCB * callback
Definition: StoreIOState.h:93
sfileno swap_filen
Definition: StoreIOState.h:84
void storeRead(StoreIOState::Pointer sio, char *buf, size_t size, off_t offset, StoreIOState::STRCB *callback, void *callback_data)
Definition: store_io.cc:82

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors