]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fs/ufs/UFSStoreState.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / fs / ufs / UFSStoreState.h
CommitLineData
58373ff8 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
58373ff8 3 *
bbc27441
AJ
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.
58373ff8
FC
7 */
8
9#ifndef SQUID_FS_UFS_UFSSTORESTATE_H
10#define SQUID_FS_UFS_UFSSTORESTATE_H
11
12#include "DiskIO/IORequestor.h"
41c97755 13#include "SquidList.h"
58373ff8
FC
14#include "StoreIOState.h"
15
16namespace Fs
17{
18namespace Ufs
19{
5c2f68b7 20
58373ff8
FC
21class UFSStoreState : public StoreIOState, public IORequestor
22{
5c2f68b7
AJ
23 CBDATA_CLASS(UFSStoreState);
24
58373ff8 25public:
58373ff8
FC
26 UFSStoreState(SwapDir * SD, StoreEntry * anEntry, STIOCB * callback_, void *callback_data_);
27 ~UFSStoreState();
28 virtual void close(int how);
29 virtual void closeCompleted();
30 // protected:
31 virtual void ioCompletedNotification();
32 virtual void readCompleted(const char *buf, int len, int errflag, RefCount<ReadRequest>);
33 virtual void writeCompleted(int errflag, size_t len, RefCount<WriteRequest>);
34 RefCount<DiskFile> theFile;
35 bool opening;
36 bool creating;
37 bool closing;
38 bool reading;
39 bool writing;
90e8b325 40 /* StoreIOState API */
58373ff8 41 void read_(char *buf, size_t size, off_t offset, STRCB * callback, void *callback_data);
90e8b325 42 virtual bool write(char const *buf, size_t size, off_t offset, FREE * free_func);
58373ff8
FC
43
44protected:
45 virtual void doCloseCallback (int errflag);
46
47 class _queued_read
48 {
58373ff8 49 MEMPROXY_CLASS(UFSStoreState::_queued_read);
741c2986 50 public:
58373ff8
FC
51 char *buf;
52 size_t size;
53 off_t offset;
54 STRCB *callback;
55 void *callback_data;
56
57 };
58
59 class _queued_write
60 {
58373ff8 61 MEMPROXY_CLASS(UFSStoreState::_queued_write);
741c2986 62 public:
58373ff8
FC
63 char const *buf;
64 size_t size;
65 off_t offset;
66 FREE *free_func;
67
68 };
69
70 /** \todo These should be in the IO strategy */
71
72 struct {
73 /**
74 * DPW 2006-05-24
75 * the write_draining flag is used to avoid recursion inside
76 * the UFSStoreState::drainWriteQueue() method.
77 */
78 bool write_draining;
79 /**
80 * DPW 2006-05-24
81 * The try_closing flag is set by UFSStoreState::tryClosing()
82 * when UFSStoreState wants to close the file, but cannot
83 * because of pending I/Os. If set, UFSStoreState will
84 * try to close again in the I/O callbacks.
85 */
86 bool try_closing;
87 } flags;
88 link_list *pending_reads;
89 link_list *pending_writes;
90 void queueRead(char *, size_t, off_t, STRCB *, void *);
91 void queueWrite(char const *, size_t, off_t, FREE *);
92 bool kickReadQueue();
93 void drainWriteQueue();
94 void tryClosing();
95 char *read_buf;
96
97private:
98 void openDone();
99 void freePending();
100 void doWrite();
58373ff8
FC
101};
102
58373ff8
FC
103} //namespace Ufs
104} //namespace Fs
105
106#endif /* SQUID_FS_UFS_UFSSTORESTATE_H */
f53969cc 107