]> git.ipfire.org Git - thirdparty/squid.git/blob - src/helper.h
Cleanup of some MemAllocatorProxy abuse. This is a MemPool internal class,
[thirdparty/squid.git] / src / helper.h
1
2 /*
3 * $Id: helper.h,v 1.6 2006/09/03 04:11:59 hno Exp $
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"
40 #include "cbdata.h"
41
42 class helper_request;
43
44 typedef struct _helper helper;
45
46 typedef struct _helper_stateful statefulhelper;
47
48 typedef struct _helper_server helper_server;
49
50 typedef struct _helper_stateful_server helper_stateful_server;
51
52 typedef struct _helper_flags helper_flags;
53
54 typedef struct _helper_stateful_flags helper_stateful_flags;
55
56 typedef stateful_helper_callback_t HLPSCB(void *, void *lastserver, char *buf);
57
58 struct _helper
59 {
60 wordlist *cmdline;
61 dlink_list servers;
62 dlink_list queue;
63 const char *id_name;
64 int n_to_start;
65 int n_running;
66 int n_active;
67 int ipc_type;
68 unsigned int concurrency;
69 time_t last_queue_warn;
70 time_t last_restart;
71
72 struct
73 {
74 int requests;
75 int replies;
76 int queue_size;
77 int avg_svc_time;
78 }
79
80 stats;
81 };
82
83 struct _helper_stateful
84 {
85 wordlist *cmdline;
86 dlink_list servers;
87 dlink_list queue;
88 const char *id_name;
89 int n_to_start;
90 int n_running;
91 int n_active;
92 int ipc_type;
93 MemAllocator *datapool;
94 HLPSAVAIL *IsAvailable;
95 HLPSONEQ *OnEmptyQueue;
96 time_t last_queue_warn;
97 time_t last_restart;
98
99 struct
100 {
101 int requests;
102 int replies;
103 int queue_size;
104 int avg_svc_time;
105 }
106
107 stats;
108 };
109
110 struct _helper_server
111 {
112 int index;
113 int pid;
114 int rfd;
115 int wfd;
116 MemBuf *wqueue;
117 MemBuf *writebuf;
118 char *rbuf;
119 size_t rbuf_sz;
120 off_t roffset;
121
122 struct timeval dispatch_time;
123
124 struct timeval answer_time;
125
126 dlink_node link;
127 helper *parent;
128 helper_request **requests;
129
130 struct _helper_flags
131 {
132
133 unsigned int writing:
134 1;
135
136 unsigned int closing:
137 1;
138
139 unsigned int shutdown:
140 1;
141 }
142
143 flags;
144
145 struct
146 {
147 int uses;
148 unsigned int pending;
149 }
150
151 stats;
152 #ifdef _SQUID_MSWIN_
153
154 HANDLE hIpc;
155 #endif
156 };
157
158 class helper_stateful_request;
159
160 struct _helper_stateful_server
161 {
162 int index;
163 int pid;
164 int rfd;
165 int wfd;
166 /* MemBuf wqueue; */
167 /* MemBuf writebuf; */
168 char *rbuf;
169 size_t rbuf_sz;
170 off_t roffset;
171
172 struct timeval dispatch_time;
173
174 struct timeval answer_time;
175
176 dlink_node link;
177 dlink_list queue;
178 statefulhelper *parent;
179 helper_stateful_request *request;
180
181 struct _helper_stateful_flags
182 {
183
184 unsigned int busy:
185 1;
186
187 unsigned int closing:
188 1;
189
190 unsigned int shutdown:
191 1;
192 stateful_helper_reserve_t reserved;
193 }
194
195 flags;
196
197 struct
198 {
199 int uses;
200 int submits;
201 int releases;
202 int deferbyfunc;
203 int deferbycb;
204 }
205
206 stats;
207 int deferred_requests; /* current number of deferred requests */
208 void *data; /* State data used by the calling routines */
209 #ifdef _SQUID_MSWIN_
210
211 HANDLE hIpc;
212 #endif
213 };
214
215 class helper_request
216 {
217
218 public:
219 MEMPROXY_CLASS(helper_request);
220 char *buf;
221 HLPCB *callback;
222 void *data;
223
224 struct timeval dispatch_time;
225 };
226
227 MEMPROXY_CLASS_INLINE(helper_request)
228
229 class helper_stateful_request
230 {
231
232 public:
233 MEMPROXY_CLASS(helper_stateful_request);
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;
238 };
239
240 MEMPROXY_CLASS_INLINE(helper_stateful_request)
241
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);
247 SQUIDCEXTERN void helperStats(StoreEntry * sentry, helper * hlp);
248 SQUIDCEXTERN void helperStatefulStats(StoreEntry * sentry, statefulhelper * hlp);
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
262 #endif /* SQUID_HELPER_H */