]>
Commit | Line | Data |
---|---|---|
a8258824 | 1 | |
9cef6668 | 2 | /* |
9bc73deb | 3 | * $Id: structs.h,v 1.307 1999/10/04 05:05:35 wessels Exp $ |
9cef6668 | 4 | * |
5 | * | |
6 | * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ | |
7 | * ---------------------------------------------------------- | |
8 | * | |
9 | * Squid is the result of efforts by numerous individuals from the | |
10 | * Internet community. Development is led by Duane Wessels of the | |
11 | * National Laboratory for Applied Network Research and funded by the | |
12 | * National Science Foundation. Squid is Copyrighted (C) 1998 by | |
13 | * Duane Wessels and the University of California San Diego. Please | |
14 | * see the COPYRIGHT file for full details. Squid incorporates | |
15 | * software developed and/or copyrighted by other sources. Please see | |
16 | * the CREDITS file for full details. | |
17 | * | |
18 | * This program is free software; you can redistribute it and/or modify | |
19 | * it under the terms of the GNU General Public License as published by | |
20 | * the Free Software Foundation; either version 2 of the License, or | |
21 | * (at your option) any later version. | |
22 | * | |
23 | * This program is distributed in the hope that it will be useful, | |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | * GNU General Public License for more details. | |
27 | * | |
28 | * You should have received a copy of the GNU General Public License | |
29 | * along with this program; if not, write to the Free Software | |
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
31 | * | |
32 | */ | |
33 | ||
0f1bc304 | 34 | struct _dlink_node { |
35 | void *data; | |
36 | dlink_node *prev; | |
37 | dlink_node *next; | |
38 | }; | |
39 | ||
40 | struct _dlink_list { | |
41 | dlink_node *head; | |
42 | dlink_node *tail; | |
43 | }; | |
44 | ||
a8258824 | 45 | struct _acl_ip_data { |
46 | struct in_addr addr1; /* if addr2 non-zero then its a range */ | |
47 | struct in_addr addr2; | |
48 | struct in_addr mask; | |
1a106e18 | 49 | acl_ip_data *next; /* used for parsing, not for storing */ |
a8258824 | 50 | }; |
51 | ||
43d4303e | 52 | struct _acl_snmp_comm { |
53 | char *name; | |
54 | void *community; | |
55 | acl_snmp_comm *next; | |
56 | }; | |
57 | ||
a8258824 | 58 | struct _acl_time_data { |
59 | int weekbits; | |
60 | int start; | |
61 | int stop; | |
74fbf3c9 | 62 | acl_time_data *next; |
a8258824 | 63 | }; |
64 | ||
65 | struct _acl_name_list { | |
66 | char name[ACL_NAME_SZ]; | |
74fbf3c9 | 67 | acl_name_list *next; |
a8258824 | 68 | }; |
69 | ||
ec878047 | 70 | struct _acl_proxy_auth_user { |
71 | /* first two items must be same as hash_link */ | |
72 | char *user; | |
73 | acl_proxy_auth_user *next; | |
73e67ee0 | 74 | /* extra fields for proxy_auth */ |
ec878047 | 75 | char *passwd; |
73e67ee0 | 76 | int passwd_ok; /* 1 = passwd checked OK */ |
77 | long expiretime; | |
9bc73deb | 78 | struct in_addr ipaddr; /* IP addr this user authenticated from */ |
79 | time_t ip_expiretime; | |
ec878047 | 80 | }; |
81 | ||
a8258824 | 82 | struct _acl_deny_info_list { |
02922e76 | 83 | int err_page_id; |
84 | char *err_page_name; | |
74fbf3c9 | 85 | acl_name_list *acl_list; |
86 | acl_deny_info_list *next; | |
a8258824 | 87 | }; |
88 | ||
66c75c41 | 89 | #if USE_ARP_ACL |
cbe3a719 | 90 | |
66c75c41 | 91 | struct _acl_arp_data { |
74b7003b | 92 | char eth[6]; |
66c75c41 | 93 | }; |
cbe3a719 | 94 | |
66c75c41 | 95 | #endif |
96 | ||
02922e76 | 97 | struct _String { |
98 | /* never reference these directly! */ | |
a369131d | 99 | unsigned short int size; /* buffer size; 64K limit */ |
100 | unsigned short int len; /* current length */ | |
02922e76 | 101 | char *buf; |
102 | }; | |
103 | ||
1df370e3 | 104 | #if SQUID_SNMP |
43d4303e | 105 | |
a9ddb359 | 106 | struct _snmp_request_t { |
5e29a294 | 107 | u_char *buf; |
108 | u_char *outbuf; | |
2ac76861 | 109 | int len; |
110 | int sock; | |
111 | long reqid; | |
112 | int outlen; | |
113 | struct sockaddr_in from; | |
114 | struct snmp_pdu *PDU; | |
115 | aclCheck_t *acl_checklist; | |
5e29a294 | 116 | u_char *community; |
a9ddb359 | 117 | }; |
bdf18524 | 118 | |
1df370e3 | 119 | #endif |
a97cfa48 | 120 | |
a8258824 | 121 | struct _acl { |
122 | char name[ACL_NAME_SZ]; | |
123 | squid_acl type; | |
124 | void *data; | |
125 | char *cfgline; | |
bd05e3e3 | 126 | acl *next; |
a8258824 | 127 | }; |
128 | ||
129 | struct _acl_list { | |
130 | int op; | |
bd05e3e3 | 131 | acl *acl; |
132 | acl_list *next; | |
a8258824 | 133 | }; |
134 | ||
135 | struct _acl_access { | |
136 | int allow; | |
bd05e3e3 | 137 | acl_list *acl_list; |
a8258824 | 138 | char *cfgline; |
bd05e3e3 | 139 | acl_access *next; |
a8258824 | 140 | }; |
141 | ||
142 | struct _aclCheck_t { | |
bd05e3e3 | 143 | const acl_access *access_list; |
a8258824 | 144 | struct in_addr src_addr; |
145 | struct in_addr dst_addr; | |
ae2c08a2 | 146 | struct in_addr my_addr; |
a8258824 | 147 | request_t *request; |
3898f57f | 148 | #if USE_IDENT |
149 | ConnStateData *conn; /* hack for ident */ | |
def67559 | 150 | char ident[USER_IDENT_SZ]; |
3898f57f | 151 | #endif |
a8258824 | 152 | char browser[BROWSERNAMELEN]; |
73e67ee0 | 153 | acl_proxy_auth_user *auth_user; |
a8258824 | 154 | acl_lookup_state state[ACL_ENUM_MAX]; |
dba79ac5 | 155 | #if SQUID_SNMP |
156 | char *snmp_community; | |
157 | #endif | |
a8258824 | 158 | PF *callback; |
159 | void *callback_data; | |
160 | }; | |
161 | ||
162 | struct _aio_result_t { | |
163 | int aio_return; | |
164 | int aio_errno; | |
165 | }; | |
166 | ||
167 | struct _wordlist { | |
168 | char *key; | |
bd05e3e3 | 169 | wordlist *next; |
a8258824 | 170 | }; |
171 | ||
172 | struct _intlist { | |
173 | int i; | |
bd05e3e3 | 174 | intlist *next; |
a8258824 | 175 | }; |
176 | ||
8f663d72 | 177 | struct _intrange { |
178 | int i; | |
179 | int j; | |
180 | intrange *next; | |
181 | }; | |
182 | ||
a8258824 | 183 | struct _ushortlist { |
184 | u_short i; | |
bd05e3e3 | 185 | ushortlist *next; |
a8258824 | 186 | }; |
187 | ||
188 | struct _relist { | |
189 | char *pattern; | |
190 | regex_t regex; | |
bd05e3e3 | 191 | relist *next; |
a8258824 | 192 | }; |
193 | ||
56e64999 | 194 | #if DELAY_POOLS |
59715b38 | 195 | struct _delaySpec { |
95e36d02 | 196 | int restore_bps; |
197 | int max_bytes; | |
198 | }; | |
1dfa1d81 | 199 | |
59715b38 | 200 | /* malloc()'d only as far as used (class * sizeof(delaySpec)! |
201 | * order of elements very important! | |
202 | */ | |
203 | struct _delaySpecSet { | |
204 | delaySpec aggregate; | |
205 | delaySpec individual; | |
206 | delaySpec network; | |
207 | }; | |
208 | ||
209 | struct _delayConfig { | |
210 | unsigned short pools; | |
211 | unsigned short initial; | |
212 | unsigned char *class; | |
213 | delaySpecSet **rates; | |
214 | acl_access **access; | |
215 | }; | |
216 | ||
56e64999 | 217 | #endif |
95e36d02 | 218 | |
a8258824 | 219 | struct _SquidConfig { |
220 | struct { | |
9906e724 | 221 | size_t maxSize; |
a8258824 | 222 | int highWaterMark; |
223 | int lowWaterMark; | |
43a70238 | 224 | } Swap; |
225 | size_t memMaxSize; | |
a8258824 | 226 | struct { |
227 | char *relayHost; | |
228 | u_short relayPort; | |
db1cd23c | 229 | peer *peer; |
a8258824 | 230 | } Wais; |
231 | struct { | |
9906e724 | 232 | size_t min; |
a8258824 | 233 | int pct; |
9906e724 | 234 | size_t max; |
a8258824 | 235 | } quickAbort; |
2b906e48 | 236 | #if HEAP_REPLACEMENT |
237 | char *replPolicy; | |
238 | #else | |
239 | /* | |
240 | * Note: the non-LRU policies do not use referenceAge, but we cannot | |
241 | * remove it until we find out how to implement #else for cf_parser.c | |
242 | */ | |
243 | #endif | |
a8258824 | 244 | time_t referenceAge; |
245 | time_t negativeTtl; | |
246 | time_t negativeDnsTtl; | |
247 | time_t positiveDnsTtl; | |
248 | time_t shutdownLifetime; | |
a8258824 | 249 | struct { |
250 | time_t read; | |
a8258824 | 251 | time_t lifetime; |
252 | time_t connect; | |
3f62decd | 253 | time_t peer_connect; |
a8258824 | 254 | time_t request; |
603a02fd | 255 | time_t pconn; |
23d92c64 | 256 | time_t siteSelect; |
dc835977 | 257 | time_t deadPeer; |
98829f69 | 258 | int icp_query; /* msec */ |
28993292 | 259 | int icp_query_max; /* msec */ |
98829f69 | 260 | int mcast_icp_query; /* msec */ |
3898f57f | 261 | #if USE_IDENT |
05832ae1 | 262 | time_t ident; |
3898f57f | 263 | #endif |
a8258824 | 264 | } Timeout; |
0483b991 | 265 | size_t maxRequestHeaderSize; |
266 | size_t maxRequestBodySize; | |
267 | size_t maxReplyBodySize; | |
a8258824 | 268 | struct { |
269 | ushortlist *http; | |
270 | u_short icp; | |
ace287ee | 271 | #if USE_HTCP |
272 | u_short htcp; | |
273 | #endif | |
1df370e3 | 274 | #if SQUID_SNMP |
678c6099 | 275 | u_short snmp; |
1df370e3 | 276 | #endif |
a8258824 | 277 | } Port; |
1df370e3 | 278 | #if SQUID_SNMP |
2bbd722b | 279 | struct { |
280 | char *configFile; | |
281 | char *agentInfo; | |
2ac237e2 | 282 | } Snmp; |
320e9f36 | 283 | #endif |
eb824054 | 284 | #if USE_WCCP |
320e9f36 | 285 | struct { |
286 | struct in_addr router; | |
eb824054 | 287 | struct in_addr incoming; |
288 | struct in_addr outgoing; | |
320e9f36 | 289 | } Wccp; |
1df370e3 | 290 | #endif |
53ad48e6 | 291 | char *as_whois_server; |
a8258824 | 292 | struct { |
293 | char *log; | |
294 | char *access; | |
295 | char *store; | |
296 | char *swap; | |
297 | char *useragent; | |
298 | int rotateNumber; | |
a8258824 | 299 | } Log; |
a8258824 | 300 | char *adminEmail; |
301 | char *effectiveUser; | |
302 | char *effectiveGroup; | |
303 | struct { | |
304 | char *dnsserver; | |
c6d5b87b | 305 | wordlist *redirect; |
f703eacb | 306 | wordlist *authenticate; |
a8258824 | 307 | char *pinger; |
308 | char *unlinkd; | |
309 | } Program; | |
310 | int dnsChildren; | |
311 | int redirectChildren; | |
73e67ee0 | 312 | int authenticateChildren; |
c68e9c6b | 313 | int authenticateTTL; |
9bc73deb | 314 | int authenticateIpTTL; |
a8258824 | 315 | struct { |
316 | char *host; | |
317 | u_short port; | |
a8258824 | 318 | } Accel; |
319 | char *appendDomain; | |
320 | size_t appendDomainLen; | |
321 | char *debugOptions; | |
322 | char *pidFilename; | |
323 | char *mimeTablePathname; | |
324 | char *visibleHostname; | |
98829f69 | 325 | char *uniqueHostname; |
1f38f50a | 326 | wordlist *hostnameAliases; |
a8258824 | 327 | char *errHtmlText; |
328 | struct { | |
329 | char *host; | |
330 | char *file; | |
331 | time_t period; | |
a8258824 | 332 | u_short port; |
333 | } Announce; | |
334 | struct { | |
335 | struct in_addr tcp_incoming; | |
336 | struct in_addr tcp_outgoing; | |
337 | struct in_addr udp_incoming; | |
2bbd722b | 338 | struct in_addr udp_outgoing; |
15dcc168 | 339 | #if SQUID_SNMP |
678c6099 | 340 | struct in_addr snmp_incoming; |
2bbd722b | 341 | struct in_addr snmp_outgoing; |
15dcc168 | 342 | #endif |
a8258824 | 343 | struct in_addr client_netmask; |
344 | } Addrs; | |
9906e724 | 345 | size_t tcpRcvBufsz; |
346 | size_t udpMaxHitObjsz; | |
a8258824 | 347 | wordlist *hierarchy_stoplist; |
348 | wordlist *mcast_group_list; | |
349 | wordlist *dns_testname_list; | |
09c483ec | 350 | wordlist *dns_nameservers; |
40a1495e | 351 | peer *peers; |
352 | int npeers; | |
a8258824 | 353 | struct { |
89de058c | 354 | int size; |
a8258824 | 355 | int low; |
356 | int high; | |
357 | } ipcache; | |
e55650e3 | 358 | struct { |
359 | int size; | |
360 | } fqdncache; | |
a8258824 | 361 | int minDirectHops; |
362 | cachemgr_passwd *passwd_list; | |
363 | struct { | |
364 | int objectsPerBucket; | |
9906e724 | 365 | size_t avgObjectSize; |
366 | size_t maxObjectSize; | |
a8258824 | 367 | } Store; |
368 | struct { | |
369 | int high; | |
370 | int low; | |
371 | time_t period; | |
372 | } Netdb; | |
373 | struct { | |
374 | int log_udp; | |
375 | int enable_purge; | |
376 | int res_defnames; | |
377 | int anonymizer; | |
378 | int client_db; | |
379 | int query_icmp; | |
88738790 | 380 | int icp_hit_stale; |
78f1250a | 381 | int buffered_logs; |
0ab965da | 382 | #if ALLOW_SOURCE_PING |
9b312a19 | 383 | int source_ping; |
0ab965da | 384 | #endif |
9b312a19 | 385 | int common_log; |
386 | int log_mime_hdrs; | |
17a0a4ee | 387 | int log_fqdn; |
388 | int announce; | |
389 | int accel_with_proxy; | |
3f6c0fb2 | 390 | int mem_pools; |
194dd3b8 | 391 | int test_reachability; |
ea285003 | 392 | int half_closed_clients; |
9f60cfdf | 393 | #if HTTP_VIOLATIONS |
465dc415 | 394 | int reload_into_ims; |
9f60cfdf | 395 | #endif |
b540e168 | 396 | int offline; |
c68e9c6b | 397 | int redir_rewrites_host; |
9b094667 | 398 | int prefer_direct; |
bcbc11b0 | 399 | int strip_query_terms; |
07476a7f | 400 | int redirector_bypass; |
9bc73deb | 401 | int ignore_unknown_nameservers; |
17a0a4ee | 402 | } onoff; |
bd05e3e3 | 403 | acl *aclList; |
a8258824 | 404 | struct { |
bd05e3e3 | 405 | acl_access *http; |
406 | acl_access *icp; | |
407 | acl_access *miss; | |
408 | acl_access *NeverDirect; | |
409 | acl_access *AlwaysDirect; | |
410 | acl_access *ASlists; | |
411 | acl_access *noCache; | |
dba79ac5 | 412 | #if SQUID_SNMP |
413 | acl_access *snmp; | |
414 | #endif | |
376bb137 | 415 | acl_access *brokenPosts; |
3898f57f | 416 | #if USE_IDENT |
a40699cd | 417 | acl_access *identLookup; |
3898f57f | 418 | #endif |
9bc73deb | 419 | acl_access *redirector; |
a8258824 | 420 | } accessList; |
bd05e3e3 | 421 | acl_deny_info_list *denyInfoList; |
f715bd3a | 422 | char *proxyAuthRealm; |
a8258824 | 423 | struct { |
424 | size_t list_width; | |
425 | int list_wrap; | |
a8258824 | 426 | char *anon_user; |
427 | } Ftp; | |
428 | refresh_t *Refresh; | |
429 | struct _cacheSwap { | |
a47b9029 | 430 | SwapDir *swapDirs; |
431 | int n_allocated; | |
432 | int n_configured; | |
a8258824 | 433 | } cacheSwap; |
88738790 | 434 | char *fake_ua; |
365cb147 | 435 | struct { |
436 | char *directory; | |
365cb147 | 437 | } icons; |
9b312a19 | 438 | char *errorDirectory; |
22c653cd | 439 | struct { |
440 | time_t timeout; | |
441 | int maxtries; | |
442 | } retry; | |
7021844c | 443 | struct { |
444 | size_t limit; | |
445 | } MemPools; | |
95e36d02 | 446 | #if DELAY_POOLS |
59715b38 | 447 | delayConfig Delay; |
95e36d02 | 448 | #endif |
6be2389e | 449 | struct { |
450 | int icp_average; | |
ef523f99 | 451 | int dns_average; |
6be2389e | 452 | int http_average; |
453 | int icp_min_poll; | |
ef523f99 | 454 | int dns_min_poll; |
6be2389e | 455 | int http_min_poll; |
456 | } comm_incoming; | |
c5f627c2 | 457 | int max_open_disk_fds; |
d548ee64 | 458 | int uri_whitespace; |
c68e9c6b | 459 | size_t rangeOffsetLimit; |
e66d7923 | 460 | #if MULTICAST_MISS_STREAM |
461 | struct { | |
462 | struct in_addr addr; | |
463 | unsigned short port; | |
464 | char *encode_key; | |
465 | } mcast_miss; | |
466 | #endif | |
5bcad01d | 467 | HttpHeaderMask anonymize_headers; |
b6a2f15e | 468 | char *coredump_dir; |
a8258824 | 469 | }; |
470 | ||
471 | struct _SquidConfig2 { | |
472 | struct { | |
473 | char *prefix; | |
474 | int on; | |
475 | } Accel; | |
476 | }; | |
477 | ||
478 | struct _close_handler { | |
479 | PF *handler; | |
480 | void *data; | |
481 | close_handler *next; | |
482 | }; | |
483 | ||
484 | struct _dread_ctrl { | |
485 | int fd; | |
486 | off_t offset; | |
487 | int req_len; | |
488 | char *buf; | |
489 | int end_of_file; | |
490 | DRCB *handler; | |
491 | void *client_data; | |
492 | }; | |
493 | ||
494 | struct _dnsserver_t { | |
495 | int id; | |
a8258824 | 496 | int inpipe; |
497 | int outpipe; | |
498 | time_t answer; | |
78f1250a | 499 | off_t offset; |
500 | size_t size; | |
e144eae4 | 501 | char ip_inbuf[DNS_INBUF_SZ]; |
a8258824 | 502 | struct timeval dispatch_time; |
503 | void *data; | |
504 | }; | |
505 | ||
506 | struct _dnsStatData { | |
507 | int requests; | |
508 | int replies; | |
509 | int hist[DefaultDnsChildrenMax]; | |
510 | }; | |
511 | ||
512 | struct _dwrite_q { | |
d377699f | 513 | off_t file_offset; |
a8258824 | 514 | char *buf; |
515 | int len; | |
d377699f | 516 | off_t buf_offset; |
bd05e3e3 | 517 | dwrite_q *next; |
74fbf3c9 | 518 | FREE *free_func; |
a8258824 | 519 | }; |
520 | ||
a9771e51 | 521 | |
522 | /* ETag support is rudimantal; | |
523 | * this struct is likely to change | |
524 | * Note: "str" points to memory in HttpHeaderEntry (for now) | |
525 | * so ETags should be used as tmp variables only (for now) */ | |
526 | struct _ETag { | |
98829f69 | 527 | const char *str; /* quoted-string */ |
528 | int weak; /* true if it is a weak validator */ | |
a9771e51 | 529 | }; |
530 | ||
a8258824 | 531 | struct _fde { |
532 | unsigned int type; | |
a8258824 | 533 | u_short local_port; |
534 | u_short remote_port; | |
535 | char ipaddr[16]; /* dotted decimal address of peer */ | |
536 | char desc[FD_DESC_SZ]; | |
58a6c186 | 537 | struct { |
60c0b5a2 | 538 | unsigned int open:1; |
3d94aed0 | 539 | unsigned int close_request:1; |
540 | unsigned int write_daemon:1; | |
541 | unsigned int closing:1; | |
542 | unsigned int socket_eof:1; | |
543 | unsigned int nolinger:1; | |
544 | unsigned int nonblocking:1; | |
545 | unsigned int ipc:1; | |
b5568a61 | 546 | unsigned int called_connect:1; |
58a6c186 | 547 | } flags; |
a8258824 | 548 | int bytes_read; |
549 | int bytes_written; | |
b716a8ad | 550 | int uses; /* ie # req's over persistent conn */ |
a8258824 | 551 | struct _fde_disk { |
552 | DWCB *wrt_handle; | |
553 | void *wrt_handle_data; | |
554 | dwrite_q *write_q; | |
555 | dwrite_q *write_q_tail; | |
711982d8 | 556 | off_t offset; |
a8258824 | 557 | } disk; |
558 | PF *read_handler; | |
559 | void *read_data; | |
560 | PF *write_handler; | |
561 | void *write_data; | |
562 | PF *timeout_handler; | |
563 | time_t timeout; | |
564 | void *timeout_data; | |
cb69b4c7 | 565 | void *lifetime_data; |
a8258824 | 566 | close_handler *close_handler; /* linked list */ |
da2b3a17 | 567 | DEFER *defer_check; /* check if we should defer read */ |
70a9dab4 | 568 | void *defer_data; |
a8258824 | 569 | CommWriteStateData *rwstate; /* State data for comm_write */ |
570 | }; | |
571 | ||
572 | struct _fileMap { | |
573 | int max_n_files; | |
574 | int n_files_in_map; | |
a8258824 | 575 | int toggle; |
576 | int nwords; | |
577 | unsigned long *file_map; | |
578 | }; | |
579 | ||
1d21d91d | 580 | /* auto-growing memory-resident buffer with printf interface */ |
581 | /* note: when updating this struct, update MemBufNULL #define */ | |
582 | struct _MemBuf { | |
583 | /* public, read-only */ | |
584 | char *buf; | |
585 | mb_size_t size; /* used space, does not count 0-terminator */ | |
586 | ||
587 | /* private, stay away; use interface function instead */ | |
588 | mb_size_t max_capacity; /* when grows: assert(new_capacity <= max_capacity) */ | |
589 | mb_size_t capacity; /* allocated space */ | |
590 | FREE *freefunc; /* what to use to free the buffer, NULL after memBufFreeFunc() is called */ | |
591 | }; | |
592 | ||
593 | /* see Packer.c for description */ | |
594 | struct _Packer { | |
595 | /* protected, use interface functions instead */ | |
596 | append_f append; | |
597 | vprintf_f vprintf; | |
598 | void *real_handler; /* first parameter to real append and vprintf */ | |
599 | }; | |
600 | ||
adba4a64 | 601 | /* http status line */ |
602 | struct _HttpStatusLine { | |
603 | /* public, read only */ | |
99edd1c3 | 604 | float version; |
2ac76861 | 605 | const char *reason; /* points to a _constant_ string (default or supplied), never free()d */ |
adba4a64 | 606 | http_status status; |
607 | }; | |
608 | ||
609 | /* | |
1d21d91d | 610 | * Note: HttpBody is used only for messages with a small content that is |
adba4a64 | 611 | * known a priory (e.g., error messages). |
612 | */ | |
613 | struct _HttpBody { | |
1d21d91d | 614 | /* private */ |
615 | MemBuf mb; | |
adba4a64 | 616 | }; |
617 | ||
2ecaa5e7 | 618 | /* http header extention field */ |
619 | struct _HttpHdrExtField { | |
a369131d | 620 | String name; /* field-name from HTTP/1.1 (no column after name) */ |
621 | String value; /* field-value from HTTP/1.1 */ | |
2ecaa5e7 | 622 | }; |
adba4a64 | 623 | |
399e85ea | 624 | /* http cache control header field */ |
7faf2bdb | 625 | struct _HttpHdrCc { |
4f087419 | 626 | int mask; |
d8b249ef | 627 | int max_age; |
a8258824 | 628 | }; |
ee1679df | 629 | |
b5107edb | 630 | /* http byte-range-spec */ |
631 | struct _HttpHdrRangeSpec { | |
9bc73deb | 632 | ssize_t offset; |
633 | ssize_t length; | |
b5107edb | 634 | }; |
635 | ||
636 | /* There may be more than one byte range specified in the request. | |
59c4d35b | 637 | * This object holds all range specs in order of their appearence |
638 | * in the request because we SHOULD preserve that order. | |
639 | */ | |
b5107edb | 640 | struct _HttpHdrRange { |
641 | Stack specs; | |
642 | }; | |
7faf2bdb | 643 | |
d76fcfa7 | 644 | /* http content-range header field */ |
645 | struct _HttpHdrContRange { | |
646 | HttpHdrRangeSpec spec; | |
9bc73deb | 647 | ssize_t elength; /* entity length, not content length */ |
d76fcfa7 | 648 | }; |
649 | ||
a9771e51 | 650 | /* some fields can hold either time or etag specs (e.g. If-Range) */ |
651 | struct _TimeOrTag { | |
98829f69 | 652 | ETag tag; /* entity tag */ |
a9771e51 | 653 | time_t time; |
98829f69 | 654 | int valid; /* true if struct is usable */ |
a9771e51 | 655 | }; |
656 | ||
d192d11f | 657 | /* data for iterating thru range specs */ |
98829f69 | 658 | struct _HttpHdrRangeIter { |
d192d11f | 659 | HttpHdrRangePos pos; |
98829f69 | 660 | const HttpHdrRangeSpec *spec; /* current spec at pos */ |
9bc73deb | 661 | ssize_t debt_size; /* bytes left to send from the current spec */ |
662 | ssize_t prefix_size; /* the size of the incoming HTTP msg prefix */ | |
98829f69 | 663 | String boundary; /* boundary for multipart responses */ |
d192d11f | 664 | }; |
d76fcfa7 | 665 | |
fcd2d3ef | 666 | /* constant attributes of http header fields */ |
667 | struct _HttpHeaderFieldAttrs { | |
668 | const char *name; | |
669 | http_hdr_type id; | |
670 | field_type type; | |
671 | }; | |
672 | ||
7faf2bdb | 673 | /* per field statistics */ |
674 | struct _HttpHeaderFieldStat { | |
399e85ea | 675 | int aliveCount; /* created but not destroyed (count) */ |
d8b249ef | 676 | int seenCount; /* #fields we've seen */ |
399e85ea | 677 | int parsCount; /* #parsing attempts */ |
678 | int errCount; /* #pasring errors */ | |
679 | int repCount; /* #repetitons */ | |
7faf2bdb | 680 | }; |
681 | ||
d8b249ef | 682 | /* compiled version of HttpHeaderFieldAttrs plus stats */ |
de336bbe | 683 | struct _HttpHeaderFieldInfo { |
684 | http_hdr_type id; | |
685 | String name; | |
686 | field_type type; | |
7faf2bdb | 687 | HttpHeaderFieldStat stat; |
688 | }; | |
689 | ||
d8b249ef | 690 | struct _HttpHeaderEntry { |
691 | http_hdr_type id; | |
692 | String name; | |
693 | String value; | |
694 | }; | |
4f087419 | 695 | |
d8b249ef | 696 | struct _HttpHeader { |
4f087419 | 697 | /* protected, do not use these, use interface functions instead */ |
ec878047 | 698 | Array entries; /* parsed fields in raw format */ |
699 | HttpHeaderMask mask; /* bit set <=> entry present */ | |
eeb423fb | 700 | http_hdr_owner_type owner; /* request or reply */ |
701 | int len; /* length when packed, not counting terminating '\0' */ | |
4f087419 | 702 | }; |
703 | ||
adba4a64 | 704 | struct _HttpReply { |
705 | /* unsupported, writable, may disappear/change in the future */ | |
2ac76861 | 706 | int hdr_sz; /* sums _stored_ status-line, headers, and <CRLF> */ |
adba4a64 | 707 | |
d8b249ef | 708 | /* public, readable; never update these or their .hdr equivalents directly */ |
709 | int content_length; | |
710 | time_t date; | |
711 | time_t last_modified; | |
712 | time_t expires; | |
ec878047 | 713 | String content_type; |
d8b249ef | 714 | HttpHdrCc *cache_control; |
715 | HttpHdrContRange *content_range; | |
9f5a2895 | 716 | short int keep_alive; |
d8b249ef | 717 | |
adba4a64 | 718 | /* public, readable */ |
2ac76861 | 719 | HttpMsgParseState pstate; /* the current parsing state */ |
4f087419 | 720 | |
de336bbe | 721 | /* public, writable, but use httpReply* interfaces when possible */ |
adba4a64 | 722 | HttpStatusLine sline; |
d8b249ef | 723 | HttpHeader header; |
724 | HttpBody body; /* for small constant memory-resident text bodies only */ | |
adba4a64 | 725 | }; |
cb69b4c7 | 726 | |
b515fc11 | 727 | struct _http_state_flags { |
79618ba9 | 728 | unsigned int proxying:1; |
729 | unsigned int keepalive:1; | |
db1cd23c | 730 | unsigned int only_if_cached:1; |
b515fc11 | 731 | }; |
a8258824 | 732 | |
733 | struct _HttpStateData { | |
734 | StoreEntry *entry; | |
735 | request_t *request; | |
736 | char *reply_hdr; | |
737 | int reply_hdr_state; | |
1294c0fc | 738 | peer *peer; /* peer request made to */ |
a8258824 | 739 | int eof; /* reached end-of-object? */ |
740 | request_t *orig_request; | |
1294c0fc | 741 | int fd; |
b515fc11 | 742 | http_state_flags flags; |
db1cd23c | 743 | FwdState *fwd; |
a8258824 | 744 | }; |
745 | ||
746 | struct _icpUdpData { | |
747 | struct sockaddr_in address; | |
748 | void *msg; | |
749 | size_t len; | |
750 | icpUdpData *next; | |
751 | #ifndef LESS_TIMING | |
752 | struct timeval start; | |
753 | #endif | |
754 | log_type logcode; | |
17b6e784 | 755 | struct timeval queue_time; |
a8258824 | 756 | }; |
757 | ||
b4e7f82d | 758 | struct _ping_data { |
a8258824 | 759 | struct timeval start; |
760 | struct timeval stop; | |
761 | int n_sent; | |
762 | int n_recv; | |
763 | int n_replies_expected; | |
98829f69 | 764 | int timeout; /* msec */ |
465dc415 | 765 | int timedout; |
a8258824 | 766 | int w_rtt; |
b3264694 | 767 | int p_rtt; |
a8258824 | 768 | }; |
769 | ||
770 | struct _HierarchyLogEntry { | |
771 | hier_code code; | |
772 | char host[SQUIDHOSTNAMELEN]; | |
b4e7f82d | 773 | ping_data ping; |
4b4cd312 | 774 | char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */ |
775 | peer_select_alg_t alg; /* peer selection algorithm */ | |
776 | lookup_t cd_lookup; /* cd prediction: none, miss, hit */ | |
777 | int n_choices; /* #peers we selected from (cd only) */ | |
778 | int n_ichoices; /* #peers with known rtt we selected from (cd only) */ | |
39edba21 | 779 | struct timeval peer_select_start; |
780 | struct timeval store_complete_stop; | |
a8258824 | 781 | }; |
782 | ||
783 | struct _AccessLogEntry { | |
784 | const char *url; | |
785 | struct { | |
786 | method_t method; | |
787 | int code; | |
788 | const char *content_type; | |
c68e9c6b | 789 | float version; |
a8258824 | 790 | } http; |
791 | struct { | |
792 | icp_opcode opcode; | |
793 | } icp; | |
794 | struct { | |
795 | struct in_addr caddr; | |
796 | size_t size; | |
797 | log_type code; | |
798 | int msec; | |
799 | const char *ident; | |
800 | } cache; | |
a8258824 | 801 | struct { |
802 | char *request; | |
803 | char *reply; | |
804 | } headers; | |
805 | struct { | |
806 | const char *method_str; | |
807 | } private; | |
bd05e3e3 | 808 | HierarchyLogEntry hier; |
a8258824 | 809 | }; |
810 | ||
811 | struct _clientHttpRequest { | |
812 | ConnStateData *conn; | |
813 | request_t *request; /* Parsed URL ... */ | |
23d92c64 | 814 | char *uri; |
815 | char *log_uri; | |
a8258824 | 816 | struct { |
78f1250a | 817 | off_t offset; |
818 | size_t size; | |
a8258824 | 819 | } out; |
98829f69 | 820 | HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ |
821 | size_t req_sz; /* raw request size on input, not current request size */ | |
a8258824 | 822 | StoreEntry *entry; |
823 | StoreEntry *old_entry; | |
824 | log_type log_type; | |
6cfa8966 | 825 | #if USE_CACHE_DIGESTS |
04f0c415 | 826 | const char *lookup_type; /* temporary hack: storeGet() result: HIT/MISS/NONE */ |
827 | #endif | |
9b312a19 | 828 | http_status http_code; |
a8258824 | 829 | struct timeval start; |
830 | float http_ver; | |
831 | int redirect_state; | |
832 | aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */ | |
833 | clientHttpRequest *next; | |
bd05e3e3 | 834 | AccessLogEntry al; |
77ed547a | 835 | struct { |
3d94aed0 | 836 | unsigned int accel:1; |
837 | unsigned int internal:1; | |
838 | unsigned int done_copying:1; | |
77ed547a | 839 | } flags; |
6d38ef86 | 840 | struct { |
841 | http_status status; | |
842 | char *location; | |
843 | } redirect; | |
0f1bc304 | 844 | dlink_node active; |
a8258824 | 845 | }; |
846 | ||
847 | struct _ConnStateData { | |
848 | int fd; | |
849 | struct { | |
850 | char *buf; | |
78f1250a | 851 | off_t offset; |
852 | size_t size; | |
a8258824 | 853 | } in; |
854 | clientHttpRequest *chr; | |
855 | struct sockaddr_in peer; | |
856 | struct sockaddr_in me; | |
857 | struct in_addr log_addr; | |
05832ae1 | 858 | char ident[USER_IDENT_SZ]; |
a8258824 | 859 | int nrequests; |
860 | int persistent; | |
da2b3a17 | 861 | struct { |
862 | int n; | |
863 | time_t until; | |
864 | } defer; | |
a8258824 | 865 | }; |
866 | ||
867 | struct _ipcache_addrs { | |
6d1c0d53 | 868 | struct in_addr *in_addrs; |
869 | unsigned char *bad_mask; | |
a8258824 | 870 | unsigned char count; |
871 | unsigned char cur; | |
22c653cd | 872 | unsigned char badcount; |
a8258824 | 873 | }; |
874 | ||
59c4d35b | 875 | struct _ip_pending { |
876 | IPH *handler; | |
877 | void *handlerData; | |
878 | ip_pending *next; | |
879 | }; | |
880 | ||
a8258824 | 881 | struct _ipcache_entry { |
ec878047 | 882 | /* first two items must be equivalent to hash_link */ |
a8258824 | 883 | char *name; |
bd05e3e3 | 884 | ipcache_entry *next; |
a8258824 | 885 | time_t lastref; |
886 | time_t expires; | |
887 | ipcache_addrs addrs; | |
59c4d35b | 888 | ip_pending *pending_head; |
a8258824 | 889 | char *error_message; |
b87b92fb | 890 | struct timeval request_time; |
2ac237e2 | 891 | dlink_node lru; |
892 | u_char locks; | |
a8258824 | 893 | ipcache_status_t status:3; |
894 | }; | |
895 | ||
59c4d35b | 896 | struct _fqdn_pending { |
897 | FQDNH *handler; | |
898 | void *handlerData; | |
899 | fqdn_pending *next; | |
900 | }; | |
901 | ||
1df370e3 | 902 | struct _fqdncache_entry { |
ec878047 | 903 | /* first two items must be equivalent to hash_link */ |
1df370e3 | 904 | char *name; |
bd05e3e3 | 905 | fqdncache_entry *next; |
1df370e3 | 906 | time_t lastref; |
907 | time_t expires; | |
908 | unsigned char name_count; | |
909 | char *names[FQDN_MAX_NAMES + 1]; | |
59c4d35b | 910 | fqdn_pending *pending_head; |
1df370e3 | 911 | char *error_message; |
74addf6c | 912 | struct timeval request_time; |
1df370e3 | 913 | dlink_node lru; |
914 | unsigned char locks; | |
915 | fqdncache_status_t status:3; | |
916 | }; | |
917 | ||
a8258824 | 918 | struct _domain_ping { |
919 | char *domain; | |
920 | int do_ping; /* boolean */ | |
bd05e3e3 | 921 | domain_ping *next; |
a8258824 | 922 | }; |
923 | ||
924 | struct _domain_type { | |
925 | char *domain; | |
926 | peer_t type; | |
bd05e3e3 | 927 | domain_type *next; |
a8258824 | 928 | }; |
929 | ||
c68e9c6b | 930 | #if USE_CACHE_DIGESTS |
e41e6dcd | 931 | struct _Version { |
4b4cd312 | 932 | short int current; /* current version */ |
933 | short int required; /* minimal version that can safely handle current version */ | |
e41e6dcd | 934 | }; |
935 | ||
936 | /* digest control block; used for transmission and storage */ | |
937 | struct _StoreDigestCBlock { | |
938 | Version ver; | |
939 | int capacity; | |
940 | int count; | |
941 | int del_count; | |
942 | int mask_size; | |
04f0c415 | 943 | unsigned char bits_per_entry; |
944 | unsigned char hash_func_count; | |
945 | short int reserved_short; | |
4b4cd312 | 946 | int reserved[32 - 6]; |
e41e6dcd | 947 | }; |
948 | ||
949 | struct _DigestFetchState { | |
e13ee7ad | 950 | PeerDigest *pd; |
e41e6dcd | 951 | StoreEntry *entry; |
952 | StoreEntry *old_entry; | |
e13ee7ad | 953 | request_t *request; |
e41e6dcd | 954 | int offset; |
955 | int mask_offset; | |
956 | time_t start_time; | |
e13ee7ad | 957 | time_t resp_time; |
958 | time_t expires; | |
959 | struct { | |
960 | int msg; | |
961 | int bytes; | |
962 | } sent, recv; | |
e41e6dcd | 963 | }; |
964 | ||
965 | /* statistics for cache digests and other hit "predictors" */ | |
966 | struct _cd_guess_stats { | |
967 | /* public, read-only */ | |
968 | int true_hits; | |
969 | int false_hits; | |
970 | int true_misses; | |
971 | int false_misses; | |
4b4cd312 | 972 | int close_hits; /* tmp, remove it later */ |
e41e6dcd | 973 | }; |
974 | ||
975 | struct _PeerDigest { | |
4d62b0af | 976 | peer *peer; /* pointer back to peer structure, argh */ |
977 | CacheDigest *cd; /* actual digest structure */ | |
978 | String host; /* copy of peer->host */ | |
e13ee7ad | 979 | const char *req_result; /* text status of the last request */ |
b515fc11 | 980 | struct { |
4d62b0af | 981 | unsigned int needed:1; /* there were requests for this digest */ |
e13ee7ad | 982 | unsigned int usable:1; /* can be used for lookups */ |
79618ba9 | 983 | unsigned int requested:1; /* in process of receiving [fresh] digest */ |
b515fc11 | 984 | } flags; |
e13ee7ad | 985 | struct { |
986 | /* all times are absolute unless augmented with _delay */ | |
987 | time_t initialized; /* creation */ | |
988 | time_t needed; /* first lookup/use by a peer */ | |
989 | time_t next_check; /* next scheduled check/refresh event */ | |
990 | time_t retry_delay; /* delay before re-checking _invalid_ digest */ | |
991 | time_t requested; /* requested a fresh copy of a digest */ | |
4d62b0af | 992 | time_t req_delay; /* last request response time */ |
e13ee7ad | 993 | time_t received; /* received the current copy of a digest */ |
994 | time_t disabled; /* disabled for good */ | |
995 | } times; | |
e41e6dcd | 996 | struct { |
997 | cd_guess_stats guess; | |
998 | int used_count; | |
e13ee7ad | 999 | struct { |
1000 | int msgs; | |
1001 | kb_t kbytes; | |
1002 | } sent, recv; | |
e41e6dcd | 1003 | } stats; |
1004 | }; | |
1005 | ||
c68e9c6b | 1006 | #endif |
1007 | ||
a8258824 | 1008 | struct _peer { |
1009 | char *host; | |
1010 | peer_t type; | |
1011 | struct sockaddr_in in_addr; | |
1012 | struct { | |
1013 | int pings_sent; | |
1014 | int pings_acked; | |
a8258824 | 1015 | int fetches; |
1016 | int rtt; | |
a8258824 | 1017 | int ignored_replies; |
1294c0fc | 1018 | int n_keepalives_sent; |
1019 | int n_keepalives_recv; | |
dc835977 | 1020 | time_t last_query; |
1021 | time_t last_reply; | |
1022 | int logged_state; /* so we can print dead/revived msgs */ | |
a8258824 | 1023 | } stats; |
399cabec | 1024 | struct { |
886f2785 | 1025 | int version; |
399cabec | 1026 | int counts[ICP_END]; |
886f2785 | 1027 | u_short port; |
399cabec | 1028 | } icp; |
1029 | #if USE_HTCP | |
1030 | struct { | |
1031 | double version; | |
1032 | int counts[2]; | |
886f2785 | 1033 | u_short port; |
399cabec | 1034 | } htcp; |
1035 | #endif | |
a8258824 | 1036 | u_short http_port; |
b6a2f15e | 1037 | domain_ping *peer_domain; |
bd05e3e3 | 1038 | domain_type *typelist; |
505e35db | 1039 | acl_access *access; |
cd196bc8 | 1040 | struct { |
79618ba9 | 1041 | unsigned int proxy_only:1; |
1042 | unsigned int no_query:1; | |
1043 | unsigned int no_digest:1; | |
1044 | unsigned int default_parent:1; | |
1045 | unsigned int roundrobin:1; | |
1046 | unsigned int mcast_responder:1; | |
1047 | unsigned int closest_only:1; | |
cd196bc8 | 1048 | #if USE_HTCP |
79618ba9 | 1049 | unsigned int htcp:1; |
cd196bc8 | 1050 | #endif |
79618ba9 | 1051 | unsigned int no_netdb_exchange:1; |
cd196bc8 | 1052 | #if DELAY_POOLS |
79618ba9 | 1053 | unsigned int no_delay:1; |
cd196bc8 | 1054 | #endif |
1055 | } options; | |
a8258824 | 1056 | int weight; |
1057 | struct { | |
1058 | double avg_n_members; | |
1059 | int n_times_counted; | |
1060 | int n_replies_expected; | |
1061 | int ttl; | |
007b8be4 | 1062 | int id; |
b515fc11 | 1063 | struct { |
79618ba9 | 1064 | unsigned int count_event_pending:1; |
1065 | unsigned int counting:1; | |
ff283ec1 | 1066 | } flags; |
a8258824 | 1067 | } mcast; |
c68e9c6b | 1068 | #if USE_CACHE_DIGESTS |
e13ee7ad | 1069 | PeerDigest *digest; |
c68e9c6b | 1070 | #endif |
a8258824 | 1071 | int tcp_up; /* 0 if a connect() fails */ |
1072 | time_t last_fail_time; | |
1073 | struct in_addr addresses[10]; | |
1074 | int n_addresses; | |
1075 | int rr_count; | |
bd05e3e3 | 1076 | peer *next; |
a8258824 | 1077 | int test_fd; |
afd88fbe | 1078 | #if USE_CARP |
1079 | struct { | |
1080 | unsigned long hash; | |
1081 | unsigned long load_multiplier; | |
1082 | float load_factor; | |
1083 | } carp; | |
1084 | #endif | |
c68e9c6b | 1085 | char *login; /* Proxy authorization */ |
3f62decd | 1086 | time_t connect_timeout; |
a8258824 | 1087 | }; |
1088 | ||
1089 | struct _net_db_name { | |
1090 | char *name; | |
74fbf3c9 | 1091 | net_db_name *htbl_next; |
1092 | net_db_name *next; | |
1093 | netdbEntry *net_db_entry; | |
a8258824 | 1094 | }; |
1095 | ||
1096 | struct _net_db_peer { | |
1097 | char *peername; | |
1098 | double hops; | |
1099 | double rtt; | |
1100 | time_t expires; | |
1101 | }; | |
1102 | ||
1103 | struct _netdbEntry { | |
ec878047 | 1104 | /* first two items must be equivalent to hash_link */ |
a8258824 | 1105 | char *key; |
74fbf3c9 | 1106 | netdbEntry *next; |
a8258824 | 1107 | char network[16]; |
1108 | int pings_sent; | |
1109 | int pings_recv; | |
1110 | double hops; | |
1111 | double rtt; | |
1112 | time_t next_ping_time; | |
1113 | time_t last_use_time; | |
1114 | int link_count; | |
1115 | net_db_name *hosts; | |
1116 | net_db_peer *peers; | |
1117 | int n_peers_alloc; | |
1118 | int n_peers; | |
1119 | }; | |
1120 | ||
1121 | struct _ps_state { | |
1122 | request_t *request; | |
1123 | StoreEntry *entry; | |
1124 | int always_direct; | |
1125 | int never_direct; | |
db1cd23c | 1126 | int direct; |
a8258824 | 1127 | PSC *callback; |
a8258824 | 1128 | void *callback_data; |
db1cd23c | 1129 | FwdServer *servers; |
85223cd7 | 1130 | /* |
1131 | * Why are these struct sockaddr_in instead of peer *? Because a | |
1132 | * peer structure can become invalid during the peer selection | |
1133 | * phase, specifically after a reconfigure. Thus we need to lookup | |
1134 | * the peer * based on the address when we are finally ready to | |
1135 | * reference the peer structure. | |
1136 | */ | |
1137 | struct sockaddr_in first_parent_miss; | |
1138 | struct sockaddr_in closest_parent_miss; | |
db1cd23c | 1139 | /* |
1140 | * ->hit and ->secho can be peer* because they should only be | |
1141 | * accessed during the thread when they are set | |
1142 | */ | |
1143 | peer *hit; | |
1144 | peer_t hit_type; | |
1145 | #if ALLOW_SOURCE_PING | |
1146 | peer *secho; | |
1147 | #endif | |
b4e7f82d | 1148 | ping_data ping; |
a8258824 | 1149 | aclCheck_t *acl_checklist; |
1150 | }; | |
1151 | ||
1152 | struct _pingerEchoData { | |
1153 | struct in_addr to; | |
1154 | unsigned char opcode; | |
1155 | int psize; | |
65ae9f56 | 1156 | char payload[PINGER_PAYLOAD_SZ]; |
a8258824 | 1157 | }; |
1158 | ||
1159 | struct _pingerReplyData { | |
1160 | struct in_addr from; | |
1161 | unsigned char opcode; | |
1162 | int rtt; | |
1163 | int hops; | |
1164 | int psize; | |
65ae9f56 | 1165 | char payload[PINGER_PAYLOAD_SZ]; |
a8258824 | 1166 | }; |
1167 | ||
1168 | struct _icp_common_t { | |
1169 | unsigned char opcode; /* opcode */ | |
1170 | unsigned char version; /* version number */ | |
1171 | unsigned short length; /* total length (bytes) */ | |
1172 | u_num32 reqnum; /* req number (req'd for UDP) */ | |
1173 | u_num32 flags; | |
1174 | u_num32 pad; | |
a8258824 | 1175 | u_num32 shostid; /* sender host id */ |
1176 | }; | |
1177 | ||
a8258824 | 1178 | struct _iostats { |
1179 | struct { | |
1180 | int reads; | |
1181 | int reads_deferred; | |
1182 | int read_hist[16]; | |
1183 | int writes; | |
1184 | int write_hist[16]; | |
1185 | } Http, Ftp, Gopher, Wais; | |
1186 | }; | |
1187 | ||
1188 | struct _mem_node { | |
1189 | char *data; | |
1190 | int len; | |
1191 | mem_node *next; | |
1192 | }; | |
1193 | ||
1194 | struct _mem_hdr { | |
1195 | mem_node *head; | |
1196 | mem_node *tail; | |
1197 | int origin_offset; | |
1198 | }; | |
1199 | ||
a8258824 | 1200 | /* keep track each client receiving data from that particular StoreEntry */ |
1201 | struct _store_client { | |
43329771 | 1202 | int type; |
a8258824 | 1203 | off_t copy_offset; |
1204 | off_t seen_offset; | |
1205 | size_t copy_size; | |
1206 | char *copy_buf; | |
1207 | STCB *callback; | |
1208 | void *callback_data; | |
07304bf9 | 1209 | StoreEntry *entry; /* ptr to the parent StoreEntry, argh! */ |
2391a162 | 1210 | storeIOState *swapin_sio; |
f115fadd | 1211 | struct { |
3d94aed0 | 1212 | unsigned int disk_io_pending:1; |
1213 | unsigned int store_copying:1; | |
1214 | unsigned int copy_event_pending:1; | |
f115fadd | 1215 | } flags; |
bd05e3e3 | 1216 | store_client *next; |
447e176b | 1217 | #if DELAY_POOLS |
1218 | delay_id delay_id; | |
1219 | #endif | |
a8258824 | 1220 | }; |
1221 | ||
1a3db59c | 1222 | |
a8258824 | 1223 | /* This structure can be freed while object is purged out from memory */ |
1224 | struct _MemObject { | |
2ac237e2 | 1225 | method_t method; |
9fb13bb6 | 1226 | char *url; |
18fe65d0 | 1227 | mem_hdr data_hdr; |
8350fe9b | 1228 | off_t inmem_hi; |
1229 | off_t inmem_lo; | |
bd05e3e3 | 1230 | store_client *clients; |
a8258824 | 1231 | int nclients; |
8350fe9b | 1232 | struct { |
e3ef2b09 | 1233 | off_t queue_offset; /* relative to in-mem data */ |
2391a162 | 1234 | storeIOState *sio; |
8350fe9b | 1235 | } swapout; |
cb69b4c7 | 1236 | HttpReply *reply; |
a8258824 | 1237 | request_t *request; |
1238 | struct timeval start_ping; | |
b4e7f82d | 1239 | IRCB *ping_reply_callback; |
a8258824 | 1240 | void *ircb_data; |
1241 | int fd; /* FD of client creating this entry */ | |
1242 | struct { | |
1243 | STABH *callback; | |
1244 | void *data; | |
1245 | } abort; | |
88738790 | 1246 | char *log_url; |
2b906e48 | 1247 | #if HEAP_REPLACEMENT |
1248 | /* | |
1249 | * A MemObject knows where it is in the in-memory heap. | |
1250 | */ | |
1251 | heap_node *node; | |
1252 | #else | |
b93bcace | 1253 | dlink_node lru; |
2b906e48 | 1254 | #endif |
007b8be4 | 1255 | int id; |
07304bf9 | 1256 | ssize_t object_sz; |
e3ef2b09 | 1257 | size_t swap_hdr_sz; |
bc87dc25 | 1258 | #if URL_CHECKSUM_DEBUG |
1259 | unsigned int chksum; | |
1260 | #endif | |
a8258824 | 1261 | }; |
1262 | ||
a8258824 | 1263 | struct _StoreEntry { |
ec878047 | 1264 | /* first two items must be same as hash_link */ |
9fb13bb6 | 1265 | const cache_key *key; |
bd05e3e3 | 1266 | StoreEntry *next; |
a8258824 | 1267 | MemObject *mem_obj; |
a8258824 | 1268 | time_t timestamp; |
1269 | time_t lastref; | |
1270 | time_t expires; | |
1271 | time_t lastmod; | |
07304bf9 | 1272 | size_t swap_file_sz; |
a21fbb54 | 1273 | u_short refcount; |
d46a87a8 | 1274 | u_short flags; |
2391a162 | 1275 | sfileno swap_file_number; |
2b906e48 | 1276 | #if HEAP_REPLACEMENT |
1277 | heap_node *node; | |
2b906e48 | 1278 | #else |
b93bcace | 1279 | dlink_node lru; |
2b906e48 | 1280 | #endif |
a3cb7458 | 1281 | u_short lock_count; /* Assume < 65536! */ |
a8258824 | 1282 | mem_status_t mem_status:3; |
1283 | ping_status_t ping_status:3; | |
1284 | store_status_t store_status:3; | |
1285 | swap_status_t swap_status:3; | |
a8258824 | 1286 | }; |
1287 | ||
1288 | struct _SwapDir { | |
0e4e0e7d | 1289 | swapdir_t type; |
1290 | fileMap *map; | |
a8258824 | 1291 | int cur_size; |
1292 | int max_size; | |
0e4e0e7d | 1293 | char *path; |
b2c141d4 | 1294 | int index; /* This entry's index into the swapDirs array */ |
a8258824 | 1295 | int suggest; |
72615e4a | 1296 | struct { |
1297 | unsigned int selected:1; | |
b6a2f15e | 1298 | unsigned int read_only:1; |
72615e4a | 1299 | } flags; |
b2c141d4 | 1300 | STINIT *init; |
1301 | STNEWFS *newfs; | |
1302 | struct { | |
1303 | STOBJOPEN *open; | |
1304 | STOBJCLOSE *close; | |
1305 | STOBJREAD *read; | |
1306 | STOBJWRITE *write; | |
1307 | STOBJUNLINK *unlink; | |
b2c141d4 | 1308 | } obj; |
1309 | struct { | |
1310 | STLOGOPEN *open; | |
1311 | STLOGCLOSE *close; | |
200ba06e | 1312 | STLOGWRITE *write; |
b2c141d4 | 1313 | struct { |
1314 | STLOGCLEANOPEN *open; | |
1315 | STLOGCLEANWRITE *write; | |
1316 | void *state; | |
1317 | } clean; | |
1318 | } log; | |
0e4e0e7d | 1319 | union { |
1320 | struct { | |
1321 | int l1; | |
1322 | int l2; | |
1323 | int swaplog_fd; | |
1324 | } ufs; | |
8798ad05 | 1325 | #if USE_DISKD |
1326 | struct { | |
1327 | int l1; | |
1328 | int l2; | |
1329 | int swaplog_fd; | |
1330 | int smsgid; | |
1331 | int rmsgid; | |
1332 | int wfd; | |
8798ad05 | 1333 | int away; |
c8366e06 | 1334 | struct { |
1335 | char *buf; | |
1336 | link_list *stack; | |
1337 | int id; | |
1338 | } shm; | |
8798ad05 | 1339 | } diskd; |
1340 | #endif | |
0e4e0e7d | 1341 | } u; |
a8258824 | 1342 | }; |
1343 | ||
92695e5e | 1344 | struct _request_flags { |
3d94aed0 | 1345 | unsigned int range:1; |
1346 | unsigned int nocache:1; | |
1347 | unsigned int ims:1; | |
1348 | unsigned int auth:1; | |
1349 | unsigned int cachable:1; | |
1350 | unsigned int hierarchical:1; | |
1351 | unsigned int loopdetect:1; | |
1352 | unsigned int proxy_keepalive:1; | |
1353 | unsigned int proxying:1; | |
1354 | unsigned int refresh:1; | |
1355 | unsigned int used_proxy_auth:1; | |
1356 | unsigned int redirected:1; | |
9689d97c | 1357 | unsigned int need_validation:1; |
9f60cfdf | 1358 | #if HTTP_VIOLATIONS |
886f2785 | 1359 | unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */ |
9f60cfdf | 1360 | #endif |
c68e9c6b | 1361 | unsigned int accelerated:1; |
1362 | unsigned int internal:1; | |
92695e5e | 1363 | }; |
1364 | ||
d03d26fb | 1365 | struct _link_list { |
1366 | void *ptr; | |
1367 | struct _link_list *next; | |
1368 | }; | |
1369 | ||
2391a162 | 1370 | struct _storeIOState { |
2391a162 | 1371 | sfileno swap_file_number; |
1372 | mode_t mode; | |
1373 | size_t st_size; /* do stat(2) after read open */ | |
1374 | off_t offset; /* current offset pointer */ | |
1375 | STIOCB *callback; | |
1376 | void *callback_data; | |
1377 | struct { | |
1378 | STRCB *callback; | |
1379 | void *callback_data; | |
1380 | } read; | |
1381 | struct { | |
1382 | unsigned int closing:1; /* debugging aid */ | |
1383 | } flags; | |
1384 | union { | |
1385 | struct { | |
819244bf | 1386 | int fd; |
2391a162 | 1387 | struct { |
1388 | unsigned int close_request:1; | |
1389 | unsigned int reading:1; | |
1390 | unsigned int writing:1; | |
1391 | } flags; | |
1392 | } ufs; | |
53fa92a5 | 1393 | struct { |
1394 | int fd; | |
53fa92a5 | 1395 | struct { |
1396 | unsigned int close_request:1; | |
1397 | unsigned int reading:1; | |
1398 | unsigned int writing:1; | |
d03d26fb | 1399 | unsigned int opening:1; |
53fa92a5 | 1400 | } flags; |
6f992224 | 1401 | const char *read_buf; |
1402 | link_list *pending_writes; | |
1f38f50a | 1403 | link_list *pending_reads; |
53fa92a5 | 1404 | } aufs; |
8798ad05 | 1405 | #if USE_DISKD |
1406 | struct { | |
1407 | int id; | |
1408 | struct { | |
1409 | unsigned int reading:1; | |
1410 | unsigned int writing:1; | |
1411 | } flags; | |
1412 | char *read_buf; | |
1413 | } diskd; | |
1414 | #endif | |
2391a162 | 1415 | } type; |
1416 | }; | |
1417 | ||
a8258824 | 1418 | struct _request_t { |
1419 | method_t method; | |
1420 | protocol_t protocol; | |
1421 | char login[MAX_LOGIN_SZ]; | |
1422 | char host[SQUIDHOSTNAMELEN + 1]; | |
def67559 | 1423 | char user_ident[USER_IDENT_SZ]; /* from proxy auth or ident server */ |
a8258824 | 1424 | u_short port; |
02922e76 | 1425 | String urlpath; |
e4a45101 | 1426 | char *canonical; |
a8258824 | 1427 | int link_count; /* free when zero */ |
92695e5e | 1428 | request_flags flags; |
8e092300 | 1429 | HttpHdrCc *cache_control; |
d192d11f | 1430 | HttpHdrRange *range; |
a8258824 | 1431 | float http_ver; |
1432 | time_t ims; | |
1433 | int imslen; | |
1434 | int max_forwards; | |
1435 | struct in_addr client_addr; | |
3c11d1f5 | 1436 | struct in_addr my_addr; |
99edd1c3 | 1437 | HttpHeader header; |
a8258824 | 1438 | char *body; |
1439 | size_t body_sz; | |
1f38f50a | 1440 | int content_length; |
bd05e3e3 | 1441 | HierarchyLogEntry hier; |
88aad2e5 | 1442 | err_type err_type; |
c68e9c6b | 1443 | char *peer_login; /* Configured peer login:password */ |
9bc73deb | 1444 | time_t lastmod; /* Used on refreshes */ |
a8258824 | 1445 | }; |
1446 | ||
1447 | struct _cachemgr_passwd { | |
1448 | char *passwd; | |
22f3fd98 | 1449 | wordlist *actions; |
bd05e3e3 | 1450 | cachemgr_passwd *next; |
a8258824 | 1451 | }; |
1452 | ||
1453 | struct _refresh_t { | |
1454 | char *pattern; | |
1455 | regex_t compiled_pattern; | |
1456 | time_t min; | |
c3f6d204 | 1457 | double pct; |
a8258824 | 1458 | time_t max; |
bd05e3e3 | 1459 | refresh_t *next; |
c3f6d204 | 1460 | struct { |
1dfa1d81 | 1461 | unsigned int icase:1; |
9f60cfdf | 1462 | #if HTTP_VIOLATIONS |
1dfa1d81 | 1463 | unsigned int override_expire:1; |
1464 | unsigned int override_lastmod:1; | |
cbe3a719 | 1465 | unsigned int reload_into_ims:1; |
1466 | unsigned int ignore_reload:1; | |
9f60cfdf | 1467 | #endif |
c3f6d204 | 1468 | } flags; |
a8258824 | 1469 | }; |
1470 | ||
1471 | struct _CommWriteStateData { | |
1472 | char *buf; | |
1473 | size_t size; | |
1474 | off_t offset; | |
1475 | CWCB *handler; | |
1476 | void *handler_data; | |
74fbf3c9 | 1477 | FREE *free_func; |
a8258824 | 1478 | }; |
9b312a19 | 1479 | |
1480 | struct _ErrorState { | |
1481 | err_type type; | |
02922e76 | 1482 | int page_id; |
9b312a19 | 1483 | http_status http_status; |
1484 | request_t *request; | |
1485 | char *url; | |
c45ed9ad | 1486 | int xerrno; |
9b312a19 | 1487 | char *host; |
1488 | u_short port; | |
1489 | char *dnsserver_msg; | |
1490 | time_t ttl; | |
1491 | struct in_addr src_addr; | |
1492 | char *redirect_url; | |
1493 | ERCB *callback; | |
1494 | void *callback_data; | |
b515fc11 | 1495 | struct { |
79618ba9 | 1496 | unsigned int flag_cbdata:1; |
b515fc11 | 1497 | } flags; |
b9916917 | 1498 | struct { |
9bc73deb | 1499 | wordlist *server_msg; |
b9916917 | 1500 | char *request; |
1501 | char *reply; | |
1502 | } ftp; | |
e144eae4 | 1503 | char *request_hdrs; |
9b312a19 | 1504 | }; |
f2908497 | 1505 | |
12cf1be2 | 1506 | /* |
1507 | * "very generic" histogram; | |
1508 | * see important comments on hbase_f restrictions in StatHist.c | |
1509 | */ | |
1510 | struct _StatHist { | |
1511 | int *bins; | |
1512 | int capacity; | |
e9a13293 | 1513 | double min; |
1514 | double max; | |
1515 | double scale; | |
95c297ec | 1516 | hbase_f *val_in; /* e.g., log() for log-based histogram */ |
1517 | hbase_f *val_out; /* e.g., exp() for log based histogram */ | |
7ae52c25 | 1518 | }; |
1519 | ||
12cf1be2 | 1520 | /* |
1521 | * if you add a field to StatCounters, | |
1d803566 | 1522 | * you MUST sync statCountersInitSpecial, statCountersClean, and statCountersCopy |
12cf1be2 | 1523 | */ |
f2908497 | 1524 | struct _StatCounters { |
1525 | struct { | |
98829f69 | 1526 | int clients; |
f2908497 | 1527 | int requests; |
1528 | int hits; | |
1529 | int errors; | |
a7c05555 | 1530 | kb_t kbytes_in; |
1531 | kb_t kbytes_out; | |
1532 | kb_t hit_kbytes_out; | |
12cf1be2 | 1533 | StatHist miss_svc_time; |
1534 | StatHist nm_svc_time; | |
7c9c84ad | 1535 | StatHist nh_svc_time; |
12cf1be2 | 1536 | StatHist hit_svc_time; |
1537 | StatHist all_svc_time; | |
f2908497 | 1538 | } client_http; |
7ae52c25 | 1539 | struct { |
a0f32775 | 1540 | struct { |
1541 | int requests; | |
1542 | int errors; | |
1543 | kb_t kbytes_in; | |
1544 | kb_t kbytes_out; | |
399e85ea | 1545 | } all , http, ftp, other; |
7ae52c25 | 1546 | } server; |
f2908497 | 1547 | struct { |
1548 | int pkts_sent; | |
071a3ae7 | 1549 | int queries_sent; |
1550 | int replies_sent; | |
f2908497 | 1551 | int pkts_recv; |
071a3ae7 | 1552 | int queries_recv; |
1553 | int replies_recv; | |
a7c05555 | 1554 | int hits_sent; |
1555 | int hits_recv; | |
8064065e | 1556 | int replies_queued; |
17b6e784 | 1557 | int replies_dropped; |
a7c05555 | 1558 | kb_t kbytes_sent; |
071a3ae7 | 1559 | kb_t q_kbytes_sent; |
1560 | kb_t r_kbytes_sent; | |
a7c05555 | 1561 | kb_t kbytes_recv; |
071a3ae7 | 1562 | kb_t q_kbytes_recv; |
1563 | kb_t r_kbytes_recv; | |
12cf1be2 | 1564 | StatHist query_svc_time; |
1565 | StatHist reply_svc_time; | |
4b4cd312 | 1566 | int query_timeouts; |
c127134a | 1567 | int times_used; |
f2908497 | 1568 | } icp; |
1569 | struct { | |
1570 | int requests; | |
1571 | } unlink; | |
9973e9fe | 1572 | struct { |
12cf1be2 | 1573 | StatHist svc_time; |
9973e9fe | 1574 | } dns; |
c127134a | 1575 | struct { |
1576 | int times_used; | |
26b164ac | 1577 | kb_t kbytes_sent; |
1578 | kb_t kbytes_recv; | |
c127134a | 1579 | kb_t memory; |
00485c29 | 1580 | int msgs_sent; |
1581 | int msgs_recv; | |
c68e9c6b | 1582 | #if USE_CACHE_DIGESTS |
4b4cd312 | 1583 | cd_guess_stats guess; |
c68e9c6b | 1584 | #endif |
69c95dd3 | 1585 | StatHist on_xition_count; |
c127134a | 1586 | } cd; |
69c95dd3 | 1587 | struct { |
1588 | int times_used; | |
1589 | } netdb; | |
f2908497 | 1590 | int page_faults; |
1591 | int select_loops; | |
d239c2f5 | 1592 | int select_fds; |
1593 | double select_time; | |
f2908497 | 1594 | double cputime; |
d5649d9f | 1595 | struct timeval timestamp; |
c6ecdbc3 | 1596 | StatHist comm_icp_incoming; |
ef523f99 | 1597 | StatHist comm_dns_incoming; |
c6ecdbc3 | 1598 | StatHist comm_http_incoming; |
26d6ee93 | 1599 | StatHist select_fds_hist; |
886f2785 | 1600 | struct { |
1601 | struct { | |
1602 | int opens; | |
1603 | int closes; | |
1604 | int reads; | |
1605 | int writes; | |
1606 | int seeks; | |
64b54eed | 1607 | int unlinks; |
886f2785 | 1608 | } disk; |
1609 | struct { | |
1610 | int accepts; | |
1611 | int sockets; | |
1612 | int connects; | |
1613 | int binds; | |
1614 | int closes; | |
1615 | int reads; | |
1616 | int writes; | |
1617 | int recvfroms; | |
1618 | int sendtos; | |
1619 | } sock; | |
1620 | #if HAVE_POLL | |
1621 | int polls; | |
1622 | #else | |
1623 | int selects; | |
1624 | #endif | |
1625 | } syscalls; | |
2c4f7ab2 | 1626 | int swap_files_cleaned; |
bfae3379 | 1627 | int aborted_requests; |
f2908497 | 1628 | }; |
69c01cd7 | 1629 | |
fcd2d3ef | 1630 | /* per header statistics */ |
1631 | struct _HttpHeaderStat { | |
1632 | const char *label; | |
1633 | HttpHeaderMask *owner_mask; | |
1634 | ||
1635 | StatHist hdrUCountDistr; | |
1636 | StatHist fieldTypeDistr; | |
1637 | StatHist ccTypeDistr; | |
1638 | ||
1639 | int parsedCount; | |
1640 | int ccParsedCount; | |
1641 | int destroyedCount; | |
1642 | int busyDestroyedCount; | |
1643 | }; | |
1644 | ||
1645 | ||
69c01cd7 | 1646 | struct _tlv { |
5830cdb3 | 1647 | char type; |
1648 | int length; | |
1649 | void *value; | |
bd05e3e3 | 1650 | tlv *next; |
5830cdb3 | 1651 | }; |
1652 | ||
07304bf9 | 1653 | struct _storeSwapLogData { |
5830cdb3 | 1654 | char op; |
2391a162 | 1655 | sfileno swap_file_number; |
5830cdb3 | 1656 | time_t timestamp; |
1657 | time_t lastref; | |
1658 | time_t expires; | |
1659 | time_t lastmod; | |
07304bf9 | 1660 | size_t swap_file_sz; |
5830cdb3 | 1661 | u_short refcount; |
d46a87a8 | 1662 | u_short flags; |
7363fc17 | 1663 | unsigned char key[MD5_DIGEST_CHARS]; |
69c01cd7 | 1664 | }; |
59c4d35b | 1665 | |
02922e76 | 1666 | /* object to track per-action memory usage (e.g. #idle objects) */ |
1667 | struct _MemMeter { | |
9bc73deb | 1668 | ssize_t level; /* current level (count or volume) */ |
1669 | ssize_t hwater_level; /* high water mark */ | |
d8b249ef | 1670 | time_t hwater_stamp; /* timestamp of last high water mark change */ |
02922e76 | 1671 | }; |
1672 | ||
1673 | /* object to track per-pool memory usage (alloc = inuse+idle) */ | |
1674 | struct _MemPoolMeter { | |
1675 | MemMeter alloc; | |
1676 | MemMeter inuse; | |
1677 | MemMeter idle; | |
1678 | gb_t saved; | |
7f8bbdcd | 1679 | gb_t total; |
02922e76 | 1680 | }; |
1681 | ||
1682 | /* a pool is a [growing] space for objects of the same size */ | |
1683 | struct _MemPool { | |
1684 | const char *label; | |
1685 | size_t obj_size; | |
1686 | Stack pstack; /* stack for free pointers */ | |
1687 | MemPoolMeter meter; | |
1688 | }; | |
1689 | ||
59c4d35b | 1690 | struct _ClientInfo { |
ec878047 | 1691 | /* first two items must be equivalent to hash_link */ |
59c4d35b | 1692 | char *key; |
ca3c5a71 | 1693 | ClientInfo *next; |
59c4d35b | 1694 | struct in_addr addr; |
1695 | struct { | |
1696 | int result_hist[LOG_TYPE_MAX]; | |
1697 | int n_requests; | |
ec878047 | 1698 | kb_t kbytes_in; |
1699 | kb_t kbytes_out; | |
1700 | kb_t hit_kbytes_out; | |
59c4d35b | 1701 | } Http, Icp; |
1702 | struct { | |
1703 | time_t time; | |
1704 | int n_req; | |
1705 | int n_denied; | |
1706 | } cutoff; | |
9bc73deb | 1707 | int n_established; /* number of current established connections */ |
59c4d35b | 1708 | }; |
c411be12 | 1709 | |
c411be12 | 1710 | struct _CacheDigest { |
1711 | /* public, read-only */ | |
1afe05c5 | 1712 | char *mask; /* bit mask */ |
1713 | size_t mask_size; /* mask size in bytes */ | |
1714 | int capacity; /* expected maximum for .count, not a hard limit */ | |
04f0c415 | 1715 | int bits_per_entry; /* number of bits allocated for each entry from capacity */ |
1afe05c5 | 1716 | int count; /* number of digested entries */ |
1717 | int del_count; /* number of deletions performed so far */ | |
c411be12 | 1718 | }; |
910169e5 | 1719 | |
db1cd23c | 1720 | struct _FwdServer { |
1721 | peer *peer; /* NULL --> origin server */ | |
1722 | hier_code code; | |
1723 | FwdServer *next; | |
1724 | }; | |
1725 | ||
910169e5 | 1726 | struct _FwdState { |
1727 | int client_fd; | |
1728 | StoreEntry *entry; | |
1729 | request_t *request; | |
1730 | FwdServer *servers; | |
6801f8a8 | 1731 | int server_fd; |
ec250dfd | 1732 | ErrorState *err; |
f563eea9 | 1733 | time_t start; |
68bd6892 | 1734 | int n_tries; |
ee08bdf5 | 1735 | struct { |
1736 | unsigned int dont_retry:1; | |
9bc73deb | 1737 | unsigned int ftp_pasv_failed:1; |
ee08bdf5 | 1738 | } flags; |
910169e5 | 1739 | }; |
1740 | ||
86aebcda | 1741 | #if USE_HTCP |
1742 | struct _htcpReplyData { | |
886f2785 | 1743 | int hit; |
1744 | HttpHeader hdr; | |
1745 | u_num32 msg_id; | |
1746 | double version; | |
1747 | struct { | |
b4e7f82d | 1748 | /* cache-to-origin */ |
886f2785 | 1749 | double rtt; |
1750 | int samp; | |
1751 | int hops; | |
1752 | } cto; | |
86aebcda | 1753 | }; |
886f2785 | 1754 | |
86aebcda | 1755 | #endif |
74addf6c | 1756 | |
1757 | ||
1758 | struct _helper_request { | |
1759 | char *buf; | |
1760 | HLPCB *callback; | |
1761 | void *data; | |
1762 | }; | |
1763 | ||
1764 | struct _helper { | |
1765 | wordlist *cmdline; | |
1766 | dlink_list servers; | |
1767 | dlink_list queue; | |
1f5f60dd | 1768 | const char *id_name; |
74addf6c | 1769 | int n_to_start; |
1770 | int n_running; | |
1771 | int ipc_type; | |
1772 | time_t last_queue_warn; | |
1773 | struct { | |
1774 | int requests; | |
1775 | int replies; | |
1776 | int queue_size; | |
1777 | int avg_svc_time; | |
1778 | } stats; | |
1779 | }; | |
1780 | ||
1781 | struct _helper_server { | |
1782 | int index; | |
1783 | int rfd; | |
1784 | int wfd; | |
1785 | char *buf; | |
1786 | size_t buf_sz; | |
1787 | off_t offset; | |
1788 | struct timeval dispatch_time; | |
1789 | struct timeval answer_time; | |
1790 | dlink_node link; | |
1791 | helper *parent; | |
1792 | helper_request *request; | |
838b993c | 1793 | struct _helper_flags { |
1794 | unsigned int alive:1; | |
1795 | unsigned int busy:1; | |
1796 | unsigned int closing:1; | |
1797 | unsigned int shutdown:1; | |
1798 | } flags; | |
74addf6c | 1799 | struct { |
1800 | int uses; | |
1801 | } stats; | |
1802 | }; | |
1803 | ||
1804 | /* | |
1805 | * use this when you need to pass callback data to a blocking | |
1806 | * operation, but you don't want to add that pointer to cbdata | |
1807 | */ | |
1808 | struct _generic_cbdata { | |
1809 | void *data; | |
1810 | }; | |
b2c141d4 | 1811 | |
1812 | struct _store_rebuild_data { | |
1813 | int objcount; /* # objects successfully reloaded */ | |
1814 | int expcount; /* # objects expired */ | |
1815 | int scancount; /* # entries scanned or read from state file */ | |
1816 | int clashcount; /* # swapfile clashes avoided */ | |
1817 | int dupcount; /* # duplicates purged */ | |
1818 | int cancelcount; /* # SWAP_LOG_DEL objects purged */ | |
1819 | int invalid; /* # bad lines */ | |
1820 | int badflags; /* # bad e->flags */ | |
1821 | int bad_log_op; | |
1822 | int zero_object_sz; | |
1823 | }; |