Squid Web Cache master
Loading...
Searching...
No Matches
StoreIOState.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
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
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_SRC_STOREIOSTATE_H */
96
#define RefCountable
The locking interface for use on Reference-Counted classes.
Definition Lock.h:66
int size
Definition ModDevPoll.cc:70
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
@ readerDone
success or failure: either way, stop swapping in
@ writerGone
failure: caller left before swapping out everything
~StoreIOState() override
off_t offset() const
void * callback_data
virtual void read_(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data)=0
RefCount< StoreIOState > Pointer
struct StoreIOState::@125 flags
STIOCB * callback
sfileno swap_filen
void STRCB(void *their_data, const char *buf, ssize_t len, StoreIOState::Pointer self)
off_t offset_
number of bytes written or read for this entry so far
STRCB * callback
StoreEntry * e
virtual void close(int how)=0
finish or abort swapping per CloseHow
bool touchingStoreEntry() const
struct StoreIOState::@124 read
virtual bool write(char const *buf, size_t size, off_t offset, FREE *free_func)=0
sdirno swap_dirn
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
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