MmappedFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 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_MMAPPEDFILE_H
10 #define SQUID_MMAPPEDFILE_H
11 
12 #include "cbdata.h"
13 #include "DiskIO/DiskFile.h"
14 #include "DiskIO/IORequestor.h"
15 
16 class MmappedFile : public DiskFile
17 {
19 
20 public:
21  MmappedFile(char const *path);
22  ~MmappedFile();
23  virtual void open(int flags, mode_t mode, RefCount<IORequestor> callback);
24  virtual void create(int flags, mode_t mode, RefCount<IORequestor> callback);
25  virtual void read(ReadRequest *);
26  virtual void write(WriteRequest *);
27  virtual void close();
28  virtual bool error() const;
29  virtual int getFD() const { return fd;}
30 
31  virtual bool canRead() const;
32  virtual bool canWrite() const;
33  virtual bool ioInProgress() const;
34 
35 private:
36  char const *path_;
38  //RefCount<ReadRequest> readRequest;
39  //RefCount<WriteRequest> writeRequest;
40  int fd;
41 
42  // mmapped memory leads to SEGV and bus errors if it maps beyond file
43  int64_t minOffset;
44  int64_t maxOffset;
45 
46  bool error_;
47 
48  void doClose();
49 };
50 
51 #endif /* SQUID_MMAPPEDFILE_H */
52 
const char * path_
Definition: MmappedFile.h:36
int64_t minOffset
enforced if not negative (to preserve file headers)
Definition: MmappedFile.h:43
virtual void open(int flags, mode_t mode, RefCount< IORequestor > callback)
Definition: MmappedFile.cc:72
RefCount< IORequestor > ioRequestor
Definition: MmappedFile.h:37
CBDATA_CLASS(MmappedFile)
virtual void create(int flags, mode_t mode, RefCount< IORequestor > callback)
Definition: MmappedFile.cc:102
virtual bool error() const
Definition: MmappedFile.cc:139
virtual void read(ReadRequest *)
Definition: MmappedFile.cc:145
int64_t maxOffset
enforced if not negative (to avoid crashes)
Definition: MmappedFile.h:44
virtual bool canWrite() const
Definition: MmappedFile.cc:133
virtual bool ioInProgress() const
we only support blocking I/O
Definition: MmappedFile.cc:215
virtual int getFD() const
Definition: MmappedFile.h:29
unsigned short mode_t
Definition: types.h:150
void const char HLPCB * callback
Definition: stub_helper.cc:16
MmappedFile(char const *path)
Definition: MmappedFile.cc:56
virtual void close()
Definition: MmappedFile.cc:118
virtual bool canRead() const
Definition: MmappedFile.cc:127
virtual void write(WriteRequest *)
Definition: MmappedFile.cc:175
void doClose()
Definition: MmappedFile.cc:108

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors