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_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
18{
19
20public:
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 {
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;
83
84 struct {
85 bool closing; /* debugging aid */
87};
88
92void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *);
93void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
94
95#endif /* SQUID_STOREIOSTATE_H */
96
#define RefCountable
The locking interface for use on Reference-Counted classes.
Definition: Lock.h:66
int size
Definition: ModDevPoll.cc:75
void storeRead(StoreIOState::Pointer, char *, size_t, off_t, StoreIOState::STRCB *, void *)
Definition: store_io.cc:79
void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *)
Definition: store_io.cc:85
void storeClose(StoreIOState::Pointer, int how)
Definition: store_io.cc:65
StoreIOState::Pointer storeOpen(StoreEntry *, StoreIOState::STIOCB *, void *)
Definition: store_io.cc:58
StoreIOState::Pointer storeCreate(StoreEntry *, StoreIOState::STIOCB *, void *)
Definition: store_io.cc:25
@ 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
@ writerGone
failure: caller left before swapping out everything
Definition: StoreIOState.h:59
~StoreIOState() override
Definition: StoreIOState.cc:44
off_t offset() const
Definition: StoreIOState.h:48
void * callback_data
Definition: StoreIOState.h:77
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)=0
RefCount< StoreIOState > Pointer
Definition: StoreIOState.h:21
STIOCB * callback
Definition: StoreIOState.h:76
sfileno swap_filen
Definition: StoreIOState.h:72
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
Definition: StoreIOState.h:29
off_t offset_
number of bytes written or read for this entry so far
Definition: StoreIOState.h:75
STRCB * callback
Definition: StoreIOState.h:80
StoreIOState(StoreIOState::STIOCB *, void *cbData)
Definition: StoreIOState.cc:30
StoreEntry * e
Definition: StoreIOState.h:73
struct StoreIOState::@143 flags
virtual void close(int how)=0
finish or abort swapping per CloseHow
bool touchingStoreEntry() const
Definition: StoreIOState.cc:55
struct StoreIOState::@142 read
virtual bool write(char const *buf, size_t size, off_t offset, FREE *free_func)=0
sdirno swap_dirn
Definition: StoreIOState.h:71
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:39
void FREE(void *)
Definition: forward.h:37
signed int sdirno
Definition: forward.h:23
signed_int32_t sfileno
Definition: forward.h:22
unsigned short mode_t
Definition: types.h:129

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors