3 * $Id: helper.h,v 1.12 2008/02/26 21:49:34 amosjeffries Exp $
5 * DEBUG: section 84 Helper process maintenance
6 * AUTHOR: Harvest Derived?
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
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.
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.
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.
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.
36 #ifndef SQUID_HELPER_H
37 #define SQUID_HELPER_H
41 #include "IPAddress.h"
45 typedef struct _helper helper
;
47 typedef struct _helper_stateful statefulhelper
;
49 typedef struct _helper_server helper_server
;
51 typedef struct _helper_stateful_server helper_stateful_server
;
53 typedef struct _helper_flags helper_flags
;
55 typedef struct _helper_stateful_flags helper_stateful_flags
;
57 typedef stateful_helper_callback_t
HLPSCB(void *, void *lastserver
, char *buf
);
69 unsigned int concurrency
;
70 time_t last_queue_warn
;
81 struct _helper_stateful
{
91 MemAllocator
*datapool
;
92 HLPSAVAIL
*IsAvailable
;
93 HLPSONEQ
*OnEmptyQueue
;
94 time_t last_queue_warn
;
105 struct _helper_server
{
117 struct timeval dispatch_time
;
119 struct timeval answer_time
;
123 helper_request
**requests
;
125 struct _helper_flags
{
126 unsigned int writing
:1;
127 unsigned int closing
:1;
128 unsigned int shutdown
:1;
133 unsigned int pending
;
139 class helper_stateful_request
;
141 struct _helper_stateful_server
{
148 /* MemBuf writebuf; */
153 struct timeval dispatch_time
;
155 struct timeval answer_time
;
159 statefulhelper
*parent
;
160 helper_stateful_request
*request
;
162 struct _helper_stateful_flags
{
164 unsigned int closing
:1;
165 unsigned int shutdown
:1;
166 stateful_helper_reserve_t reserved
;
176 int deferred_requests
; /* current number of deferred requests */
177 void *data
; /* State data used by the calling routines */
185 MEMPROXY_CLASS(helper_request
);
190 struct timeval dispatch_time
;
193 MEMPROXY_CLASS_INLINE(helper_request
) /**DOCS_NOSEMI*/
195 class helper_stateful_request
199 MEMPROXY_CLASS(helper_stateful_request
);
202 int placeholder
; /* if 1, this is a dummy request waiting for a stateful helper to become available for deferred requests.*/
206 MEMPROXY_CLASS_INLINE(helper_stateful_request
) /**DOCS_NOSEMI*/
209 SQUIDCEXTERN
void helperOpenServers(helper
* hlp
);
210 SQUIDCEXTERN
void helperStatefulOpenServers(statefulhelper
* hlp
);
211 SQUIDCEXTERN
void helperSubmit(helper
* hlp
, const char *buf
, HLPCB
* callback
, void *data
);
212 SQUIDCEXTERN
void helperStatefulSubmit(statefulhelper
* hlp
, const char *buf
, HLPSCB
* callback
, void *data
, helper_stateful_server
* lastserver
);
213 SQUIDCEXTERN
void helperStats(StoreEntry
* sentry
, helper
* hlp
, const char *label
= NULL
);
214 SQUIDCEXTERN
void helperStatefulStats(StoreEntry
* sentry
, statefulhelper
* hlp
, const char *label
= NULL
);
215 SQUIDCEXTERN
void helperShutdown(helper
* hlp
);
216 SQUIDCEXTERN
void helperStatefulShutdown(statefulhelper
* hlp
);
217 SQUIDCEXTERN helper
*helperCreate(const char *);
218 SQUIDCEXTERN statefulhelper
*helperStatefulCreate(const char *);
219 SQUIDCEXTERN
void helperFree(helper
*);
220 SQUIDCEXTERN
void helperStatefulFree(statefulhelper
*);
221 SQUIDCEXTERN
void helperStatefulReset(helper_stateful_server
* srv
);
222 SQUIDCEXTERN
void helperStatefulReleaseServer(helper_stateful_server
* srv
);
223 SQUIDCEXTERN
void *helperStatefulServerGetData(helper_stateful_server
* srv
);
224 SQUIDCEXTERN helper_stateful_server
*helperStatefulDefer(statefulhelper
*);
228 #endif /* SQUID_HELPER_H */