]>
Commit | Line | Data |
---|---|---|
51ee7c82 | 1 | /* |
51ee7c82 | 2 | * DEBUG: section 84 Helper process maintenance |
3 | * AUTHOR: Harvest Derived? | |
4 | * | |
5 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
6 | * ---------------------------------------------------------- | |
7 | * | |
8 | * Squid is the result of efforts by numerous individuals from | |
9 | * the Internet community; see the CONTRIBUTORS file for full | |
10 | * details. Many organizations have provided support for Squid's | |
11 | * development; see the SPONSORS file for full details. Squid is | |
12 | * Copyrighted (C) 2001 by the Regents of the University of | |
13 | * California; see the COPYRIGHT file for full details. Squid | |
14 | * incorporates software developed and/or copyrighted by other | |
15 | * sources; see the CREDITS file for full details. | |
16 | * | |
17 | * This program is free software; you can redistribute it and/or modify | |
18 | * it under the terms of the GNU General Public License as published by | |
19 | * the Free Software Foundation; either version 2 of the License, or | |
20 | * (at your option) any later version. | |
26ac0430 | 21 | * |
51ee7c82 | 22 | * This program is distributed in the hope that it will be useful, |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU General Public License for more details. | |
26ac0430 | 26 | * |
51ee7c82 | 27 | * You should have received a copy of the GNU General Public License |
28 | * along with this program; if not, write to the Free Software | |
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
30 | * | |
31 | */ | |
32 | ||
33 | #ifndef SQUID_HELPER_H | |
34 | #define SQUID_HELPER_H | |
35 | ||
36 | #include "squid.h" | |
aa839030 | 37 | #include "cbdata.h" |
9837e5f0 | 38 | #include "ip/IpAddress.h" |
aa839030 | 39 | |
40 | class helper_request; | |
41 | ||
42 | typedef struct _helper helper; | |
43 | ||
44 | typedef struct _helper_stateful statefulhelper; | |
45 | ||
46 | typedef struct _helper_server helper_server; | |
47 | ||
48 | typedef struct _helper_stateful_server helper_stateful_server; | |
49 | ||
50 | typedef struct _helper_flags helper_flags; | |
51 | ||
52 | typedef struct _helper_stateful_flags helper_stateful_flags; | |
53 | ||
54 | typedef stateful_helper_callback_t HLPSCB(void *, void *lastserver, char *buf); | |
55 | ||
26ac0430 | 56 | struct _helper { |
aa839030 | 57 | wordlist *cmdline; |
58 | dlink_list servers; | |
59 | dlink_list queue; | |
60 | const char *id_name; | |
d974a072 AJ |
61 | int n_to_start; ///< Configuration setting of how many helper children should be running |
62 | int n_running; ///< Total helper children objects currently existing | |
63 | int n_active; ///< Count of helper children active (not shutting down) | |
aa839030 | 64 | int ipc_type; |
ad61a2b4 | 65 | IpAddress addr; |
aa839030 | 66 | unsigned int concurrency; |
67 | time_t last_queue_warn; | |
68 | time_t last_restart; | |
69 | ||
26ac0430 | 70 | struct { |
aa839030 | 71 | int requests; |
72 | int replies; | |
73 | int queue_size; | |
74 | int avg_svc_time; | |
2fadd50d | 75 | } stats; |
aa839030 | 76 | }; |
77 | ||
26ac0430 | 78 | struct _helper_stateful { |
aa839030 | 79 | wordlist *cmdline; |
80 | dlink_list servers; | |
81 | dlink_list queue; | |
82 | const char *id_name; | |
d974a072 AJ |
83 | int n_to_start; ///< Configuration setting of how many helper children should be running |
84 | int n_running; ///< Total helper children objects currently existing | |
85 | int n_active; ///< Count of helper children active (not shutting down) | |
aa839030 | 86 | int ipc_type; |
ad61a2b4 | 87 | IpAddress addr; |
a3efa961 | 88 | MemAllocator *datapool; |
aa839030 | 89 | HLPSAVAIL *IsAvailable; |
90 | HLPSONEQ *OnEmptyQueue; | |
91 | time_t last_queue_warn; | |
92 | time_t last_restart; | |
93 | ||
26ac0430 | 94 | struct { |
aa839030 | 95 | int requests; |
96 | int replies; | |
97 | int queue_size; | |
98 | int avg_svc_time; | |
2fadd50d | 99 | } stats; |
aa839030 | 100 | }; |
101 | ||
26ac0430 | 102 | struct _helper_server { |
aa839030 | 103 | int index; |
104 | int pid; | |
ad61a2b4 | 105 | IpAddress addr; |
aa839030 | 106 | int rfd; |
107 | int wfd; | |
108 | MemBuf *wqueue; | |
109 | MemBuf *writebuf; | |
110 | char *rbuf; | |
111 | size_t rbuf_sz; | |
57d55dfa | 112 | size_t roffset; |
aa839030 | 113 | |
114 | struct timeval dispatch_time; | |
115 | ||
116 | struct timeval answer_time; | |
117 | ||
118 | dlink_node link; | |
119 | helper *parent; | |
120 | helper_request **requests; | |
121 | ||
26ac0430 | 122 | struct _helper_flags { |
3d0ac046 HN |
123 | unsigned int writing:1; |
124 | unsigned int closing:1; | |
125 | unsigned int shutdown:1; | |
126 | } flags; | |
aa839030 | 127 | |
26ac0430 | 128 | struct { |
aa839030 | 129 | int uses; |
130 | unsigned int pending; | |
3d0ac046 | 131 | } stats; |
cc192b50 | 132 | |
9d88e312 | 133 | void *hIpc; |
aa839030 | 134 | }; |
135 | ||
136 | class helper_stateful_request; | |
137 | ||
26ac0430 | 138 | struct _helper_stateful_server { |
aa839030 | 139 | int index; |
140 | int pid; | |
ad61a2b4 | 141 | IpAddress addr; |
aa839030 | 142 | int rfd; |
143 | int wfd; | |
144 | /* MemBuf wqueue; */ | |
145 | /* MemBuf writebuf; */ | |
146 | char *rbuf; | |
147 | size_t rbuf_sz; | |
57d55dfa | 148 | size_t roffset; |
aa839030 | 149 | |
150 | struct timeval dispatch_time; | |
151 | ||
152 | struct timeval answer_time; | |
153 | ||
154 | dlink_node link; | |
aa839030 | 155 | statefulhelper *parent; |
156 | helper_stateful_request *request; | |
157 | ||
26ac0430 | 158 | struct _helper_stateful_flags { |
3d0ac046 HN |
159 | unsigned int busy:1; |
160 | unsigned int closing:1; | |
161 | unsigned int shutdown:1; | |
360d26ea | 162 | unsigned int reserved:1; |
3d0ac046 | 163 | } flags; |
aa839030 | 164 | |
26ac0430 | 165 | struct { |
aa839030 | 166 | int uses; |
167 | int submits; | |
168 | int releases; | |
3d0ac046 | 169 | } stats; |
aa839030 | 170 | void *data; /* State data used by the calling routines */ |
9d88e312 | 171 | void *hIpc; |
aa839030 | 172 | }; |
51ee7c82 | 173 | |
174 | class helper_request | |
175 | { | |
176 | ||
177 | public: | |
b001e822 | 178 | MEMPROXY_CLASS(helper_request); |
51ee7c82 | 179 | char *buf; |
180 | HLPCB *callback; | |
181 | void *data; | |
182 | ||
183 | struct timeval dispatch_time; | |
51ee7c82 | 184 | }; |
185 | ||
d85b8894 | 186 | MEMPROXY_CLASS_INLINE(helper_request); |
b001e822 | 187 | |
51ee7c82 | 188 | class helper_stateful_request |
189 | { | |
190 | ||
191 | public: | |
b001e822 | 192 | MEMPROXY_CLASS(helper_stateful_request); |
51ee7c82 | 193 | char *buf; |
194 | HLPSCB *callback; | |
d20ce97d | 195 | int placeholder; /* if 1, this is a dummy request waiting for a stateful helper to become available */ |
51ee7c82 | 196 | void *data; |
51ee7c82 | 197 | }; |
198 | ||
d85b8894 | 199 | MEMPROXY_CLASS_INLINE(helper_stateful_request); |
b001e822 | 200 | |
aa839030 | 201 | /* helper.c */ |
202 | SQUIDCEXTERN void helperOpenServers(helper * hlp); | |
203 | SQUIDCEXTERN void helperStatefulOpenServers(statefulhelper * hlp); | |
204 | SQUIDCEXTERN void helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data); | |
205 | SQUIDCEXTERN void helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, void *data, helper_stateful_server * lastserver); | |
9522b380 | 206 | SQUIDCEXTERN void helperStats(StoreEntry * sentry, helper * hlp, const char *label = NULL); |
207 | SQUIDCEXTERN void helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp, const char *label = NULL); | |
aa839030 | 208 | SQUIDCEXTERN void helperShutdown(helper * hlp); |
209 | SQUIDCEXTERN void helperStatefulShutdown(statefulhelper * hlp); | |
210 | SQUIDCEXTERN helper *helperCreate(const char *); | |
211 | SQUIDCEXTERN statefulhelper *helperStatefulCreate(const char *); | |
212 | SQUIDCEXTERN void helperFree(helper *); | |
213 | SQUIDCEXTERN void helperStatefulFree(statefulhelper *); | |
aa839030 | 214 | SQUIDCEXTERN void helperStatefulReleaseServer(helper_stateful_server * srv); |
215 | SQUIDCEXTERN void *helperStatefulServerGetData(helper_stateful_server * srv); | |
aa839030 | 216 | |
217 | ||
218 | ||
51ee7c82 | 219 | #endif /* SQUID_HELPER_H */ |