]> git.ipfire.org Git - thirdparty/squid.git/blame - src/fde.h
Release notes updates
[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"
96d89ea0 34#include "ip/Address.h"
528b2c61 35
781ce8ff 36class PconnPool;
37
62e76326 38class fde
39{
40
528b2c61 41public:
cc192b50 42 fde() { clear(); };
9e008dda 43
82ec8dfc
AR
44 /// True if comm_close for this fd has been called
45 bool closing() { return flags.close_request; }
cc192b50 46
75faaa7a 47 /* NOTE: memset is used on fdes today. 20030715 RBC */
528b2c61 48 static void DumpStats (StoreEntry *);
62e76326 49
528b2c61 50 char const *remoteAddr() const;
51 void dumpStats (StoreEntry &, int);
52 bool readPending(int);
781ce8ff 53 void noteUse(PconnPool *);
528b2c61 54
55 unsigned int type;
528b2c61 56 u_short remote_port;
62e76326 57
b7ac5457 58 Ip::Address local_addr;
528b2c61 59 unsigned char tos;
cc192b50 60 int sock_family;
61 char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
528b2c61 62 char desc[FD_DESC_SZ];
62e76326 63
9e008dda
AJ
64 struct {
65 unsigned int open:1;
66 unsigned int close_request:1; // file_ or comm_close has been called
67 unsigned int write_daemon:1;
68 unsigned int socket_eof:1;
69 unsigned int nolinger:1;
70 unsigned int nonblocking:1;
71 unsigned int ipc:1;
72 unsigned int called_connect:1;
73 unsigned int nodelay:1;
74 unsigned int close_on_exec:1;
75 unsigned int read_pending:1;
76 unsigned int write_pending:1;
3949d8b7 77 unsigned int transparent:1;
aeb090a2 78 } flags;
62e76326 79
47f6e231 80 int64_t bytes_read;
81 int64_t bytes_written;
781ce8ff 82
aeb090a2 83 struct {
781ce8ff 84 int uses; /* ie # req's over persistent conn */
85 PconnPool *pool;
aeb090a2 86 } pconn;
781ce8ff 87
751406fe 88 unsigned epoll_state;
62e76326 89
528b2c61 90 struct _fde_disk disk;
91 PF *read_handler;
92 void *read_data;
93 PF *write_handler;
94 void *write_data;
5c2c2194 95 AsyncCall::Pointer timeoutHandler;
528b2c61 96 time_t timeout;
5ef5e5cc 97 time_t writeStart;
528b2c61 98 void *lifetime_data;
5c2c2194 99 AsyncCall::Pointer closeHandler;
74257126 100 AsyncCall::Pointer halfClosedReader; /// read handler for half-closed fds
51026b54 101 CommWriteStateData *wstate; /* State data for comm_write */
528b2c61 102 READ_HANDLER *read_method;
103 WRITE_HANDLER *write_method;
104#if USE_SSL
105 SSL *ssl;
528b2c61 106#endif
629b5f75 107#ifdef _SQUID_MSWIN_
9e008dda 108 struct {
629b5f75 109 long handle;
aeb090a2 110 } win32;
629b5f75 111#endif
7172612f
AJ
112#if USE_ZPH_QOS
113 unsigned char upstreamTOS; /* see FwdState::dispatch() */
114#endif
629b5f75 115
bf81adb4
AR
116private:
117 /** Clear the fde class back to NULL equivalent. */
118 inline void clear() {
119 timeoutHandler = NULL;
120 closeHandler = NULL;
74257126 121 halfClosedReader = NULL;
bf81adb4
AR
122 // XXX: the following memset may corrupt or leak new or changed members
123 memset(this, 0, sizeof(fde));
b7ac5457 124 local_addr.SetEmpty(); // Ip::Address likes to be setup nicely.
bf81adb4 125 }
9e008dda 126
528b2c61 127};
128
04f55905
AJ
129SQUIDCEXTERN int fdNFree(void);
130
ef364f64
AJ
131#define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
132#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
133
528b2c61 134#endif /* SQUID_FDE_H */