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