fde.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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_FDE_H
10 #define SQUID_FDE_H
11 
12 #include "comm.h"
13 #include "defines.h"
14 #include "ip/Address.h"
15 #include "ip/forward.h"
16 #include "security/forward.h"
17 #include "typedefs.h" //DRCB, DWCB
18 
19 #if USE_DELAY_POOLS
20 #include "MessageBucket.h"
21 class ClientInfo;
22 #endif
23 class dwrite_q;
24 
29 typedef int READ_HANDLER(int, char *, int);
30 
35 typedef int WRITE_HANDLER(int, const char *, int);
36 
37 class _fde_disk
38 {
39 public:
40  _fde_disk() { wrt_handle = nullptr; }
41 
43  void *wrt_handle_data = nullptr;
44  dwrite_q *write_q = nullptr;
45  dwrite_q *write_q_tail = nullptr;
46  off_t offset = 0;
47 };
48 
49 class fde
50 {
51 
52 public:
53  fde() {
54  *ipaddr = 0;
55  *desc = 0;
56  read_handler = nullptr;
57  write_handler = nullptr;
58  read_method = nullptr;
59  write_method = nullptr;
60  }
61 
63  void clear() { *this = fde(); }
64 
66  bool closing() const { return flags.close_request; }
67 
68  /* NOTE: memset is used on fdes today. 20030715 RBC */
69  static void DumpStats(StoreEntry *);
70 
71  char const *remoteAddr() const;
72  void dumpStats(StoreEntry &, int) const;
73  bool readPending(int) const;
74 
76  void noteUse() { ++pconn.uses; }
77 
78 public:
79 
81  static fde* Table;
82 
83  unsigned int type = 0;
84  unsigned short remote_port = 0;
85 
87  tos_t tosToServer = '\0';
91  int sock_family = 0;
92  char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
94 
95  struct _fde_flags {
96  bool open = false;
97  bool close_request = false;
98  bool write_daemon = false;
99  bool socket_eof = false;
100  bool nolinger = false;
101  bool nonblocking = false;
102  bool ipc = false;
103  bool called_connect = false;
104  bool nodelay = false;
105  bool close_on_exec = false;
106  bool read_pending = false;
107  //bool write_pending; //XXX seems not to be used
108  bool transparent = false;
109  } flags;
110 
111  int64_t bytes_read = 0;
112  int64_t bytes_written = 0;
113 
114  struct {
115  int uses = 0; /* ie # req's over persistent conn */
116  } pconn;
117 
118 #if USE_DELAY_POOLS
119  ClientInfo * clientInfo = nullptr;
122 #endif
123  unsigned epoll_state = 0;
124 
127  void *read_data = nullptr;
129  void *write_data = nullptr;
131  time_t timeout = 0;
132  time_t writeStart = 0;
133  void *lifetime_data = nullptr;
140 #if _SQUID_WINDOWS_
141  struct {
142  long handle = (long)nullptr;
143  } win32;
144 #endif
150  unsigned int nfmarkFromServer = 0;
155 };
156 
157 #define fd_table fde::Table
158 
159 int fdNFree(void);
160 
161 #define FD_READ_METHOD(fd, buf, len) (*fde::Table[fd].read_method)(fd, buf, len)
162 #define FD_WRITE_METHOD(fd, buf, len) (*fde::Table[fd].write_method)(fd, buf, len)
163 
164 #endif /* SQUID_FDE_H */
165 
bool nolinger
Definition: fde.h:100
Definition: fde.h:37
_fde_disk disk
Definition: fde.h:125
struct fde::_fde_flags flags
bool close_request
true if file_ or comm_close has been called
Definition: fde.h:97
static void DumpStats(StoreEntry *)
Definition: fde.cc:55
Ip::Address local_addr
Definition: fde.h:86
int fdNFree(void)
Definition: fd.cc:300
unsigned short remote_port
Definition: fde.h:84
static fde * Table
global table of FD and their state.
Definition: fde.h:81
_fde_disk()
Definition: fde.h:40
void * lifetime_data
Definition: fde.h:133
dwrite_q * write_q_tail
Definition: fde.h:45
unsigned int nfmarkFromServer
Definition: fde.h:150
void DWCB(int, int, size_t, void *)
Definition: typedefs.h:18
tos_t tosToServer
Definition: fde.h:87
bool called_connect
Definition: fde.h:103
Security::ContextPointer dynamicTlsContext
cached and then freed when fd is closed
Definition: fde.h:139
int64_t bytes_written
Definition: fde.h:112
bool nodelay
Definition: fde.h:104
unsigned int type
Definition: fde.h:83
struct fde::@68 pconn
char const * remoteAddr() const
Definition: fde.cc:84
PF * write_handler
Definition: fde.h:128
AsyncCall::Pointer closeHandler
Definition: fde.h:134
int sock_family
Definition: fde.h:91
unsigned char tos_t
Definition: forward.h:26
Definition: fs_io.h:33
bool close_on_exec
Definition: fde.h:105
READ_HANDLER * read_method
read handler for half-closed fds
Definition: fde.h:136
int64_t bytes_read
Definition: fde.h:111
tos_t tosFromServer
Definition: fde.h:145
void * wrt_handle_data
Definition: fde.h:43
PF * read_handler
Definition: fde.h:126
dwrite_q * write_q
Definition: fde.h:44
bool nonblocking
Definition: fde.h:101
bool ipc
Definition: fde.h:102
#define FD_DESC_SZ
Definition: defines.h:46
time_t writeStart
Definition: fde.h:132
void * write_data
Definition: fde.h:129
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:28
void PF(int, void *)
Definition: forward.h:18
void * read_data
Definition: fde.h:127
void noteUse()
record a transaction on this FD
Definition: fde.h:76
SMB_Handle_Type handle
int WRITE_HANDLER(int, const char *, int)
Definition: fde.h:35
AsyncCall::Pointer halfClosedReader
Definition: fde.h:135
bool readPending(int) const
Definition: fde.cc:22
Security::SessionPointer ssl
Definition: fde.h:138
void dumpStats(StoreEntry &, int) const
Definition: fde.cc:31
int READ_HANDLER(int, char *, int)
Definition: fde.h:29
DWCB * wrt_handle
Definition: fde.h:42
bool socket_eof
Definition: fde.h:99
nfmark_t nfmarkToServer
Definition: fde.h:89
bool read_pending
Definition: fde.h:106
unsigned epoll_state
Definition: fde.h:123
void clear()
Clear the fde class back to NULL equivalent.
Definition: fde.h:63
AsyncCall::Pointer timeoutHandler
Definition: fde.h:130
WRITE_HANDLER * write_method
Definition: fde.h:137
bool open
Definition: fde.h:96
off_t offset
Definition: fde.h:46
bool write_daemon
Definition: fde.h:98
bool transparent
Definition: fde.h:108
Definition: fde.h:49
time_t timeout
Definition: fde.h:131
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:23
int uses
Definition: fde.h:115
fde()
Definition: fde.h:53
bool closing() const
True if comm_close for this fd has been called.
Definition: fde.h:66
char ipaddr[MAX_IPSTRLEN]
Definition: fde.h:92
char desc[FD_DESC_SZ]
Definition: fde.h:93
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition: fde.h:121
uint32_t nfmark_t
Definition: forward.h:25
ClientInfo * clientInfo
pointer to client info used in client write limiter or nullptr if not present
Definition: fde.h:120
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors