]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fde.h
Windows: fix detection of GNU atomis operations
[thirdparty/squid.git] / src / fde.h
CommitLineData
528b2c61 1/*
528b2c61 2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
9e008dda 18 *
528b2c61 19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
9e008dda 23 *
528b2c61 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29
30#ifndef SQUID_FDE_H
31#define SQUID_FDE_H
cc192b50 32
a46d2c0e 33#include "comm.h"
1328cfb7 34#include "defines.h"
96d89ea0 35#include "ip/Address.h"
528b2c61 36
a011edee
FC
37#if USE_SSL
38#include <openssl/ssl.h>
39#endif
40
9a0a18de 41#if USE_DELAY_POOLS
b4cd430a
CT
42class ClientInfo;
43#endif
1328cfb7 44
781ce8ff 45class PconnPool;
1328cfb7 46class dwrite_q;
e4a14600
A
47class _fde_disk
48{
1328cfb7
FC
49public:
50 DWCB *wrt_handle;
51 void *wrt_handle_data;
52 dwrite_q *write_q;
53 dwrite_q *write_q_tail;
54 off_t offset;
82afb125 55 _fde_disk() { memset(this, 0, sizeof(_fde_disk)); }
1328cfb7 56};
781ce8ff 57
62e76326 58class fde
59{
60
528b2c61 61public:
cc192b50 62 fde() { clear(); };
9e008dda 63
82ec8dfc
AR
64 /// True if comm_close for this fd has been called
65 bool closing() { return flags.close_request; }
cc192b50 66
75faaa7a 67 /* NOTE: memset is used on fdes today. 20030715 RBC */
528b2c61 68 static void DumpStats (StoreEntry *);
62e76326 69
528b2c61 70 char const *remoteAddr() const;
71 void dumpStats (StoreEntry &, int);
72 bool readPending(int);
781ce8ff 73 void noteUse(PconnPool *);
528b2c61 74
b115733c 75public:
528b2c61 76 unsigned int type;
f45dd259 77 unsigned short remote_port;
62e76326 78
b7ac5457 79 Ip::Address local_addr;
425de4c8
AJ
80 tos_t tosToServer; /**< The TOS value for packets going towards the server.
81 See also tosFromServer. */
82 nfmark_t nfmarkToServer; /**< The netfilter mark for packets going towards the server.
83 See also nfmarkFromServer. */
cc192b50 84 int sock_family;
85 char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
528b2c61 86 char desc[FD_DESC_SZ];
62e76326 87
b115733c 88 struct _fde_flags {
9e008dda
AJ
89 unsigned int open:1;
90 unsigned int close_request:1; // file_ or comm_close has been called
91 unsigned int write_daemon:1;
92 unsigned int socket_eof:1;
93 unsigned int nolinger:1;
94 unsigned int nonblocking:1;
95 unsigned int ipc:1;
96 unsigned int called_connect:1;
97 unsigned int nodelay:1;
98 unsigned int close_on_exec:1;
99 unsigned int read_pending:1;
100 unsigned int write_pending:1;
3949d8b7 101 unsigned int transparent:1;
aeb090a2 102 } flags;
62e76326 103
47f6e231 104 int64_t bytes_read;
105 int64_t bytes_written;
781ce8ff 106
aeb090a2 107 struct {
781ce8ff 108 int uses; /* ie # req's over persistent conn */
109 PconnPool *pool;
aeb090a2 110 } pconn;
781ce8ff 111
9a0a18de 112#if USE_DELAY_POOLS
b4cd430a
CT
113 ClientInfo * clientInfo;/* pointer to client info used in client write limiter or NULL if not present */
114#endif
751406fe 115 unsigned epoll_state;
62e76326 116
82afb125 117 _fde_disk disk;
528b2c61 118 PF *read_handler;
119 void *read_data;
120 PF *write_handler;
121 void *write_data;
5c2c2194 122 AsyncCall::Pointer timeoutHandler;
528b2c61 123 time_t timeout;
5ef5e5cc 124 time_t writeStart;
528b2c61 125 void *lifetime_data;
5c2c2194 126 AsyncCall::Pointer closeHandler;
74257126 127 AsyncCall::Pointer halfClosedReader; /// read handler for half-closed fds
51026b54 128 CommWriteStateData *wstate; /* State data for comm_write */
528b2c61 129 READ_HANDLER *read_method;
130 WRITE_HANDLER *write_method;
131#if USE_SSL
132 SSL *ssl;
95d2589c 133 SSL_CTX *dynamicSslContext; ///< cached and then freed when fd is closed
528b2c61 134#endif
1191b93b 135#if _SQUID_MSWIN_
9e008dda 136 struct {
629b5f75 137 long handle;
aeb090a2 138 } win32;
629b5f75 139#endif
425de4c8
AJ
140 tos_t tosFromServer; /**< Stores the TOS flags of the packets from the remote server.
141 See FwdState::dispatch(). Note that this differs to
142 tosToServer in that this is the value we *receive* from the,
143 connection, whereas tosToServer is the value to set on packets
144 *leaving* Squid. */
145 unsigned int nfmarkFromServer; /**< Stores the Netfilter mark value of the connection from the remote
146 server. See FwdState::dispatch(). Note that this differs to
147 nfmarkToServer in that this is the value we *receive* from the,
148 connection, whereas nfmarkToServer is the value to set on packets
149 *leaving* Squid. */
629b5f75 150
bf81adb4
AR
151private:
152 /** Clear the fde class back to NULL equivalent. */
153 inline void clear() {
b115733c
AJ
154 type = 0;
155 remote_port = 0;
156 local_addr.SetEmpty();
f4f6c2e0
AJ
157 tosToServer = '\0';
158 nfmarkToServer = 0;
b115733c
AJ
159 sock_family = 0;
160 memset(ipaddr, '\0', MAX_IPSTRLEN);
161 memset(desc,'\0',FD_DESC_SZ);
9b8bdcab 162 memset(&flags,0,sizeof(_fde_flags));
b115733c
AJ
163 bytes_read = 0;
164 bytes_written = 0;
165 pconn.uses = 0;
166 pconn.pool = NULL;
9a0a18de 167#if USE_DELAY_POOLS
b4cd430a 168 clientInfo = NULL;
d15c7ffc 169#endif
b115733c 170 epoll_state = 0;
b115733c
AJ
171 read_handler = NULL;
172 read_data = NULL;
173 write_handler = NULL;
174 write_data = NULL;
bf81adb4 175 timeoutHandler = NULL;
b115733c
AJ
176 timeout = 0;
177 writeStart = 0;
178 lifetime_data = NULL;
bf81adb4 179 closeHandler = NULL;
74257126 180 halfClosedReader = NULL;
b115733c
AJ
181 wstate = NULL;
182 read_method = NULL;
183 write_method = NULL;
184#if USE_SSL
185 ssl = NULL;
95d2589c 186 dynamicSslContext = NULL;
b115733c 187#endif
1191b93b 188#if _SQUID_MSWIN_
b115733c
AJ
189 win32.handle = NULL;
190#endif
f4f6c2e0
AJ
191 tosFromServer = '\0';
192 nfmarkFromServer = 0;
bf81adb4 193 }
528b2c61 194};
195
d9c252f2 196int fdNFree(void);
04f55905 197
ef364f64
AJ
198#define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
199#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
200
528b2c61 201#endif /* SQUID_FDE_H */