2 * DEBUG: section 84 Helper process maintenance
3 * AUTHOR: Harvest Derived?
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
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.
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.
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.
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.
34 #include "base/AsyncCbdataCalls.h"
36 #include "comm/Connection.h"
37 #include "comm/Write.h"
39 #include "format/Quoting.h"
44 #include "SquidMath.h"
45 #include "SquidTime.h"
49 #define HELPER_MAX_ARGS 64
51 /** Initial Squid input buffer size. Helper responses may exceed this, and
52 * Squid will grow the input buffer as needed, up to ReadBufMaxSize.
54 const size_t ReadBufMinSize(4*1024);
56 /** Maximum safe size of a helper-to-Squid response message plus one.
57 * Squid will warn and close the stream if a helper sends a too-big response.
58 * ssl_crtd helper is known to produce responses of at least 10KB in size.
59 * Some undocumented helpers are known to produce responses exceeding 8KB.
61 const size_t ReadBufMaxSize(32*1024);
63 static IOCB helperHandleRead
;
64 static IOCB helperStatefulHandleRead
;
65 static void helperServerFree(helper_server
*srv
);
66 static void helperStatefulServerFree(helper_stateful_server
*srv
);
67 static void Enqueue(helper
* hlp
, helper_request
*);
68 static helper_request
*Dequeue(helper
* hlp
);
69 static helper_stateful_request
*StatefulDequeue(statefulhelper
* hlp
);
70 static helper_server
*GetFirstAvailable(helper
* hlp
);
71 static helper_stateful_server
*StatefulGetFirstAvailable(statefulhelper
* hlp
);
72 static void helperDispatch(helper_server
* srv
, helper_request
* r
);
73 static void helperStatefulDispatch(helper_stateful_server
* srv
, helper_stateful_request
* r
);
74 static void helperKickQueue(helper
* hlp
);
75 static void helperStatefulKickQueue(statefulhelper
* hlp
);
76 static void helperStatefulServerDone(helper_stateful_server
* srv
);
77 static void helperRequestFree(helper_request
* r
);
78 static void helperStatefulRequestFree(helper_stateful_request
* r
);
79 static void StatefulEnqueue(statefulhelper
* hlp
, helper_stateful_request
* r
);
80 static bool helperStartStats(StoreEntry
*sentry
, void *hlp
, const char *label
);
82 CBDATA_CLASS_INIT(helper
);
83 CBDATA_TYPE(helper_server
);
84 CBDATA_CLASS_INIT(statefulhelper
);
85 CBDATA_TYPE(helper_stateful_server
);
88 HelperServerBase::initStats()
97 HelperServerBase::closePipesSafely()
102 shutdown(writePipe
->fd
, SD_BOTH
);
105 flags
.closing
= true;
106 if (readPipe
->fd
== writePipe
->fd
)
114 if (WaitForSingleObject(hIpc
, 5000) != WAIT_OBJECT_0
) {
116 debugs(84, DBG_IMPORTANT
, "WARNING: " << hlp
->id_name
<<
117 " #" << no
<< " (" << hlp
->cmdline
->key
<< "," <<
118 (long int)pid
<< ") didn't exit in 5 seconds");
126 HelperServerBase::closeWritePipeSafely()
131 shutdown(writePipe
->fd
, (readPipe
->fd
== writePipe
->fd
? SD_BOTH
: SD_SEND
));
134 flags
.closing
= true;
135 if (readPipe
->fd
== writePipe
->fd
)
141 if (WaitForSingleObject(hIpc
, 5000) != WAIT_OBJECT_0
) {
143 debugs(84, DBG_IMPORTANT
, "WARNING: " << hlp
->id_name
<<
144 " #" << no
<< " (" << hlp
->cmdline
->key
<< "," <<
145 (long int)pid
<< ") didn't exit in 5 seconds");
153 helperOpenServers(helper
* hlp
)
159 const char *args
[HELPER_MAX_ARGS
+1]; // save space for a NULL terminator
160 char fd_note_buf
[FD_DESC_SZ
];
170 if (hlp
->cmdline
== NULL
)
173 progname
= hlp
->cmdline
->key
;
175 if ((s
= strrchr(progname
, '/')))
176 shortname
= xstrdup(s
+ 1);
178 shortname
= xstrdup(progname
);
180 /* figure out how many new child are actually needed. */
181 int need_new
= hlp
->childs
.needNew();
183 debugs(84, DBG_IMPORTANT
, "helperOpenServers: Starting " << need_new
<< "/" << hlp
->childs
.n_max
<< " '" << shortname
<< "' processes");
186 debugs(84, DBG_IMPORTANT
, "helperOpenServers: No '" << shortname
<< "' processes needed.");
189 procname
= (char *)xmalloc(strlen(shortname
) + 3);
191 snprintf(procname
, strlen(shortname
) + 3, "(%s)", shortname
);
193 args
[nargs
] = procname
;
196 for (w
= hlp
->cmdline
->next
; w
&& nargs
< HELPER_MAX_ARGS
; w
= w
->next
) {
197 args
[nargs
] = w
->key
;
204 assert(nargs
<= HELPER_MAX_ARGS
);
206 for (k
= 0; k
< need_new
; ++k
) {
209 pid
= ipcCreate(hlp
->ipc_type
,
219 debugs(84, DBG_IMPORTANT
, "WARNING: Cannot run '" << progname
<< "' process.");
223 ++ hlp
->childs
.n_running
;
224 ++ hlp
->childs
.n_active
;
225 CBDATA_INIT_TYPE(helper_server
);
226 srv
= cbdataAlloc(helper_server
);
231 srv
->addr
= hlp
->addr
;
232 srv
->readPipe
= new Comm::Connection
;
233 srv
->readPipe
->fd
= rfd
;
234 srv
->writePipe
= new Comm::Connection
;
235 srv
->writePipe
->fd
= wfd
;
236 srv
->rbuf
= (char *)memAllocBuf(ReadBufMinSize
, &srv
->rbuf_sz
);
237 srv
->wqueue
= new MemBuf
;
239 srv
->requests
= (helper_request
**)xcalloc(hlp
->childs
.concurrency
? hlp
->childs
.concurrency
: 1, sizeof(*srv
->requests
));
240 srv
->parent
= cbdataReference(hlp
);
241 dlinkAddTail(srv
, &srv
->link
, &hlp
->servers
);
244 snprintf(fd_note_buf
, FD_DESC_SZ
, "%s #%d", shortname
, k
+ 1);
245 fd_note(rfd
, fd_note_buf
);
247 snprintf(fd_note_buf
, FD_DESC_SZ
, "reading %s #%d", shortname
, k
+ 1);
248 fd_note(rfd
, fd_note_buf
);
249 snprintf(fd_note_buf
, FD_DESC_SZ
, "writing %s #%d", shortname
, k
+ 1);
250 fd_note(wfd
, fd_note_buf
);
253 commSetNonBlocking(rfd
);
256 commSetNonBlocking(wfd
);
258 AsyncCall::Pointer closeCall
= asyncCall(5,4, "helperServerFree", cbdataDialer(helperServerFree
, srv
));
259 comm_add_close_handler(rfd
, closeCall
);
261 AsyncCall::Pointer call
= commCbCall(5,4, "helperHandleRead",
262 CommIoCbPtrFun(helperHandleRead
, srv
));
263 comm_read(srv
->readPipe
, srv
->rbuf
, srv
->rbuf_sz
- 1, call
);
266 hlp
->last_restart
= squid_curtime
;
267 safe_free(shortname
);
269 helperKickQueue(hlp
);
275 * helperStatefulOpenServers: create the stateful child helper processes
278 helperStatefulOpenServers(statefulhelper
* hlp
)
281 const char *args
[HELPER_MAX_ARGS
+1]; // save space for a NULL terminator
282 char fd_note_buf
[FD_DESC_SZ
];
285 if (hlp
->cmdline
== NULL
)
288 if (hlp
->childs
.concurrency
)
289 debugs(84, DBG_CRITICAL
, "ERROR: concurrency= is not yet supported for stateful helpers ('" << hlp
->cmdline
<< "')");
291 char *progname
= hlp
->cmdline
->key
;
294 if ((s
= strrchr(progname
, '/')))
295 shortname
= xstrdup(s
+ 1);
297 shortname
= xstrdup(progname
);
299 /* figure out haw mant new helpers are needed. */
300 int need_new
= hlp
->childs
.needNew();
302 debugs(84, DBG_IMPORTANT
, "helperOpenServers: Starting " << need_new
<< "/" << hlp
->childs
.n_max
<< " '" << shortname
<< "' processes");
305 debugs(84, DBG_IMPORTANT
, "helperStatefulOpenServers: No '" << shortname
<< "' processes needed.");
308 char *procname
= (char *)xmalloc(strlen(shortname
) + 3);
310 snprintf(procname
, strlen(shortname
) + 3, "(%s)", shortname
);
312 args
[nargs
] = procname
;
315 for (wordlist
*w
= hlp
->cmdline
->next
; w
&& nargs
< HELPER_MAX_ARGS
; w
= w
->next
) {
316 args
[nargs
] = w
->key
;
323 assert(nargs
<= HELPER_MAX_ARGS
);
325 for (int k
= 0; k
< need_new
; ++k
) {
330 pid_t pid
= ipcCreate(hlp
->ipc_type
,
340 debugs(84, DBG_IMPORTANT
, "WARNING: Cannot run '" << progname
<< "' process.");
344 ++ hlp
->childs
.n_running
;
345 ++ hlp
->childs
.n_active
;
346 CBDATA_INIT_TYPE(helper_stateful_server
);
347 helper_stateful_server
*srv
= cbdataAlloc(helper_stateful_server
);
350 srv
->flags
.reserved
= false;
353 srv
->addr
= hlp
->addr
;
354 srv
->readPipe
= new Comm::Connection
;
355 srv
->readPipe
->fd
= rfd
;
356 srv
->writePipe
= new Comm::Connection
;
357 srv
->writePipe
->fd
= wfd
;
358 srv
->rbuf
= (char *)memAllocBuf(ReadBufMinSize
, &srv
->rbuf_sz
);
360 srv
->parent
= cbdataReference(hlp
);
362 if (hlp
->datapool
!= NULL
)
363 srv
->data
= hlp
->datapool
->alloc();
365 dlinkAddTail(srv
, &srv
->link
, &hlp
->servers
);
368 snprintf(fd_note_buf
, FD_DESC_SZ
, "%s #%d", shortname
, k
+ 1);
369 fd_note(rfd
, fd_note_buf
);
371 snprintf(fd_note_buf
, FD_DESC_SZ
, "reading %s #%d", shortname
, k
+ 1);
372 fd_note(rfd
, fd_note_buf
);
373 snprintf(fd_note_buf
, FD_DESC_SZ
, "writing %s #%d", shortname
, k
+ 1);
374 fd_note(wfd
, fd_note_buf
);
377 commSetNonBlocking(rfd
);
380 commSetNonBlocking(wfd
);
382 AsyncCall::Pointer closeCall
= asyncCall(5,4, "helperStatefulServerFree", cbdataDialer(helperStatefulServerFree
, srv
));
383 comm_add_close_handler(rfd
, closeCall
);
385 AsyncCall::Pointer call
= commCbCall(5,4, "helperStatefulHandleRead",
386 CommIoCbPtrFun(helperStatefulHandleRead
, srv
));
387 comm_read(srv
->readPipe
, srv
->rbuf
, srv
->rbuf_sz
- 1, call
);
390 hlp
->last_restart
= squid_curtime
;
391 safe_free(shortname
);
393 helperStatefulKickQueue(hlp
);
397 helperSubmit(helper
* hlp
, const char *buf
, HLPCB
* callback
, void *data
)
400 debugs(84, 3, "helperSubmit: hlp == NULL");
401 HelperReply nilReply
;
402 callback(data
, nilReply
);
406 helper_request
*r
= new helper_request
;
409 r
->callback
= callback
;
410 r
->data
= cbdataReference(data
);
411 r
->buf
= xstrdup(buf
);
413 if ((srv
= GetFirstAvailable(hlp
)))
414 helperDispatch(srv
, r
);
418 debugs(84, DBG_DATA
, Raw("buf", buf
, strlen(buf
)));
421 /// lastserver = "server last used as part of a reserved request sequence"
423 helperStatefulSubmit(statefulhelper
* hlp
, const char *buf
, HLPCB
* callback
, void *data
, helper_stateful_server
* lastserver
)
426 debugs(84, 3, "helperStatefulSubmit: hlp == NULL");
427 HelperReply nilReply
;
428 callback(data
, nilReply
);
432 helper_stateful_request
*r
= new helper_stateful_request
;
434 r
->callback
= callback
;
435 r
->data
= cbdataReference(data
);
438 r
->buf
= xstrdup(buf
);
445 if ((buf
!= NULL
) && lastserver
) {
446 debugs(84, 5, "StatefulSubmit with lastserver " << lastserver
);
447 assert(lastserver
->flags
.reserved
);
448 assert(!(lastserver
->request
));
450 debugs(84, 5, "StatefulSubmit dispatching");
451 helperStatefulDispatch(lastserver
, r
);
453 helper_stateful_server
*srv
;
454 if ((srv
= StatefulGetFirstAvailable(hlp
))) {
455 helperStatefulDispatch(srv
, r
);
457 StatefulEnqueue(hlp
, r
);
460 debugs(84, DBG_DATA
, "placeholder: '" << r
->placeholder
<<
461 "', " << Raw("buf", buf
, strlen(buf
)));
467 * helperStatefulReleaseServer tells the helper that whoever was
468 * using it no longer needs its services.
471 helperStatefulReleaseServer(helper_stateful_server
* srv
)
473 debugs(84, 3, HERE
<< "srv-" << srv
->index
<< " flags.reserved = " << srv
->flags
.reserved
);
474 if (!srv
->flags
.reserved
)
477 ++ srv
->stats
.releases
;
479 srv
->flags
.reserved
= false;
480 if (srv
->parent
->OnEmptyQueue
!= NULL
&& srv
->data
)
481 srv
->parent
->OnEmptyQueue(srv
->data
);
483 helperStatefulServerDone(srv
);
486 /** return a pointer to the stateful routines data area */
488 helperStatefulServerGetData(helper_stateful_server
* srv
)
494 * Dump some stats about the helper states to a StoreEntry
497 helperStats(StoreEntry
* sentry
, helper
* hlp
, const char *label
)
499 if (!helperStartStats(sentry
, hlp
, label
))
502 storeAppendPrintf(sentry
, "program: %s\n",
504 storeAppendPrintf(sentry
, "number active: %d of %d (%d shutting down)\n",
505 hlp
->childs
.n_active
, hlp
->childs
.n_max
, (hlp
->childs
.n_running
- hlp
->childs
.n_active
) );
506 storeAppendPrintf(sentry
, "requests sent: %d\n",
507 hlp
->stats
.requests
);
508 storeAppendPrintf(sentry
, "replies received: %d\n",
510 storeAppendPrintf(sentry
, "queue length: %d\n",
511 hlp
->stats
.queue_size
);
512 storeAppendPrintf(sentry
, "avg service time: %d msec\n",
513 hlp
->stats
.avg_svc_time
);
514 storeAppendPrintf(sentry
, "\n");
515 storeAppendPrintf(sentry
, "%7s\t%7s\t%7s\t%11s\t%11s\t%s\t%7s\t%7s\t%7s\n",
526 for (dlink_node
*link
= hlp
->servers
.head
; link
; link
= link
->next
) {
527 helper_server
*srv
= (helper_server
*)link
->data
;
528 double tt
= 0.001 * (srv
->requests
[0] ? tvSubMsec(srv
->requests
[0]->dispatch_time
, current_time
) : tvSubMsec(srv
->dispatch_time
, srv
->answer_time
));
529 storeAppendPrintf(sentry
, "%7d\t%7d\t%7d\t%11" PRIu64
"\t%11" PRIu64
"%c%c%c%c\t%7.3f\t%7d\t%s\n",
535 srv
->stats
.pending
? 'B' : ' ',
536 srv
->flags
.writing
? 'W' : ' ',
537 srv
->flags
.closing
? 'C' : ' ',
538 srv
->flags
.shutdown
? 'S' : ' ',
541 srv
->requests
[0] ? Format::QuoteMimeBlob(srv
->requests
[0]->buf
) : "(none)");
544 storeAppendPrintf(sentry
, "\nFlags key:\n\n");
545 storeAppendPrintf(sentry
, " B = BUSY\n");
546 storeAppendPrintf(sentry
, " W = WRITING\n");
547 storeAppendPrintf(sentry
, " C = CLOSING\n");
548 storeAppendPrintf(sentry
, " S = SHUTDOWN PENDING\n");
552 helperStatefulStats(StoreEntry
* sentry
, statefulhelper
* hlp
, const char *label
)
554 if (!helperStartStats(sentry
, hlp
, label
))
557 storeAppendPrintf(sentry
, "program: %s\n",
559 storeAppendPrintf(sentry
, "number active: %d of %d (%d shutting down)\n",
560 hlp
->childs
.n_active
, hlp
->childs
.n_max
, (hlp
->childs
.n_running
- hlp
->childs
.n_active
) );
561 storeAppendPrintf(sentry
, "requests sent: %d\n",
562 hlp
->stats
.requests
);
563 storeAppendPrintf(sentry
, "replies received: %d\n",
565 storeAppendPrintf(sentry
, "queue length: %d\n",
566 hlp
->stats
.queue_size
);
567 storeAppendPrintf(sentry
, "avg service time: %d msec\n",
568 hlp
->stats
.avg_svc_time
);
569 storeAppendPrintf(sentry
, "\n");
570 storeAppendPrintf(sentry
, "%7s\t%7s\t%7s\t%11s\t%11s\t%6s\t%7s\t%7s\t%7s\n",
581 for (dlink_node
*link
= hlp
->servers
.head
; link
; link
= link
->next
) {
582 helper_stateful_server
*srv
= (helper_stateful_server
*)link
->data
;
583 double tt
= 0.001 * tvSubMsec(srv
->dispatch_time
, srv
->flags
.busy
? current_time
: srv
->answer_time
);
584 storeAppendPrintf(sentry
, "%7d\t%7d\t%7d\t%11" PRIu64
"\t%11" PRIu64
"\t%c%c%c%c%c\t%7.3f\t%7d\t%s\n",
590 srv
->flags
.busy
? 'B' : ' ',
591 srv
->flags
.closing
? 'C' : ' ',
592 srv
->flags
.reserved
? 'R' : ' ',
593 srv
->flags
.shutdown
? 'S' : ' ',
594 srv
->request
? (srv
->request
->placeholder
? 'P' : ' ') : ' ',
597 srv
->request
? Format::QuoteMimeBlob(srv
->request
->buf
) : "(none)");
600 storeAppendPrintf(sentry
, "\nFlags key:\n\n");
601 storeAppendPrintf(sentry
, " B = BUSY\n");
602 storeAppendPrintf(sentry
, " C = CLOSING\n");
603 storeAppendPrintf(sentry
, " R = RESERVED\n");
604 storeAppendPrintf(sentry
, " S = SHUTDOWN PENDING\n");
605 storeAppendPrintf(sentry
, " P = PLACEHOLDER\n");
609 helperShutdown(helper
* hlp
)
611 dlink_node
*link
= hlp
->servers
.head
;
615 srv
= (helper_server
*)link
->data
;
618 if (srv
->flags
.shutdown
) {
619 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " has already SHUT DOWN.");
623 assert(hlp
->childs
.n_active
> 0);
624 -- hlp
->childs
.n_active
;
625 srv
->flags
.shutdown
= true; /* request it to shut itself down */
627 if (srv
->flags
.closing
) {
628 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is CLOSING.");
632 if (srv
->stats
.pending
) {
633 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is BUSY.");
637 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " shutting down.");
638 /* the rest of the details is dealt with in the helperServerFree
641 srv
->closePipesSafely();
646 helperStatefulShutdown(statefulhelper
* hlp
)
648 dlink_node
*link
= hlp
->servers
.head
;
649 helper_stateful_server
*srv
;
652 srv
= (helper_stateful_server
*)link
->data
;
655 if (srv
->flags
.shutdown
) {
656 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " has already SHUT DOWN.");
660 assert(hlp
->childs
.n_active
> 0);
661 -- hlp
->childs
.n_active
;
662 srv
->flags
.shutdown
= true; /* request it to shut itself down */
664 if (srv
->flags
.busy
) {
665 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is BUSY.");
669 if (srv
->flags
.closing
) {
670 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is CLOSING.");
674 if (srv
->flags
.reserved
) {
676 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is RESERVED. Closing anyway.");
678 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is RESERVED. Not Shutting Down Yet.");
683 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " shutting down.");
685 /* the rest of the details is dealt with in the helperStatefulServerFree
688 srv
->closePipesSafely();
694 /* note, don't free id_name, it probably points to static memory */
697 debugs(84, DBG_CRITICAL
, "WARNING: freeing " << id_name
<< " helper with " << stats
.queue_size
<< " requests queued");
700 /* ====================================================================== */
701 /* LOCAL FUNCTIONS */
702 /* ====================================================================== */
705 helperServerFree(helper_server
*srv
)
707 helper
*hlp
= srv
->parent
;
709 int i
, concurrency
= hlp
->childs
.concurrency
;
715 memFreeBuf(srv
->rbuf_sz
, srv
->rbuf
);
719 srv
->wqueue
->clean();
723 srv
->writebuf
->clean();
724 delete srv
->writebuf
;
725 srv
->writebuf
= NULL
;
728 if (Comm::IsConnOpen(srv
->writePipe
))
729 srv
->closeWritePipeSafely();
731 dlinkDelete(&srv
->link
, &hlp
->servers
);
733 assert(hlp
->childs
.n_running
> 0);
734 -- hlp
->childs
.n_running
;
736 if (!srv
->flags
.shutdown
) {
737 assert(hlp
->childs
.n_active
> 0);
738 -- hlp
->childs
.n_active
;
739 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " exited");
741 if (hlp
->childs
.needNew() > 0) {
742 debugs(80, DBG_IMPORTANT
, "Too few " << hlp
->id_name
<< " processes are running (need " << hlp
->childs
.needNew() << "/" << hlp
->childs
.n_max
<< ")");
744 if (hlp
->childs
.n_active
< hlp
->childs
.n_startup
&& hlp
->last_restart
> squid_curtime
- 30) {
745 if (srv
->stats
.replies
< 1)
746 fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp
->id_name
);
748 debugs(80, DBG_CRITICAL
, "ERROR: The " << hlp
->id_name
<< " helpers are crashing too rapidly, need help!");
751 debugs(80, DBG_IMPORTANT
, "Starting new helpers");
752 helperOpenServers(hlp
);
756 for (i
= 0; i
< concurrency
; ++i
) {
757 // XXX: re-schedule these on another helper?
758 if ((r
= srv
->requests
[i
])) {
761 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
762 HelperReply nilReply
;
763 r
->callback(cbdata
, nilReply
);
766 helperRequestFree(r
);
768 srv
->requests
[i
] = NULL
;
771 safe_free(srv
->requests
);
773 cbdataReferenceDone(srv
->parent
);
778 helperStatefulServerFree(helper_stateful_server
*srv
)
780 statefulhelper
*hlp
= srv
->parent
;
781 helper_stateful_request
*r
;
784 memFreeBuf(srv
->rbuf_sz
, srv
->rbuf
);
789 srv
->wqueue
->clean();
795 /* TODO: walk the local queue of requests and carry them all out */
796 if (Comm::IsConnOpen(srv
->writePipe
))
797 srv
->closeWritePipeSafely();
799 dlinkDelete(&srv
->link
, &hlp
->servers
);
801 assert(hlp
->childs
.n_running
> 0);
802 -- hlp
->childs
.n_running
;
804 if (!srv
->flags
.shutdown
) {
805 assert( hlp
->childs
.n_active
> 0);
806 -- hlp
->childs
.n_active
;
807 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " exited");
809 if (hlp
->childs
.needNew() > 0) {
810 debugs(80, DBG_IMPORTANT
, "Too few " << hlp
->id_name
<< " processes are running (need " << hlp
->childs
.needNew() << "/" << hlp
->childs
.n_max
<< ")");
812 if (hlp
->childs
.n_active
< hlp
->childs
.n_startup
&& hlp
->last_restart
> squid_curtime
- 30) {
813 if (srv
->stats
.replies
< 1)
814 fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp
->id_name
);
816 debugs(80, DBG_CRITICAL
, "ERROR: The " << hlp
->id_name
<< " helpers are crashing too rapidly, need help!");
819 debugs(80, DBG_IMPORTANT
, "Starting new helpers");
820 helperStatefulOpenServers(hlp
);
824 if ((r
= srv
->request
)) {
827 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
828 HelperReply nilReply
;
829 nilReply
.whichServer
= srv
;
830 r
->callback(cbdata
, nilReply
);
833 helperStatefulRequestFree(r
);
838 if (srv
->data
!= NULL
)
839 hlp
->datapool
->freeOne(srv
->data
);
841 cbdataReferenceDone(srv
->parent
);
846 /// Calls back with a pointer to the buffer with the helper output
848 helperReturnBuffer(int request_number
, helper_server
* srv
, helper
* hlp
, char * msg
, char * msg_end
)
850 helper_request
*r
= srv
->requests
[request_number
];
852 HLPCB
*callback
= r
->callback
;
854 srv
->requests
[request_number
] = NULL
;
859 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
860 HelperReply
response(msg
, (msg_end
-msg
));
861 callback(cbdata
, response
);
864 -- srv
->stats
.pending
;
865 ++ srv
->stats
.replies
;
867 ++ hlp
->stats
.replies
;
869 srv
->answer_time
= current_time
;
871 srv
->dispatch_time
= r
->dispatch_time
;
873 hlp
->stats
.avg_svc_time
=
874 Math::intAverage(hlp
->stats
.avg_svc_time
,
875 tvSubMsec(r
->dispatch_time
, current_time
),
876 hlp
->stats
.replies
, REDIRECT_AV_FACTOR
);
878 helperRequestFree(r
);
880 debugs(84, DBG_IMPORTANT
, "helperHandleRead: unexpected reply on channel " <<
881 request_number
<< " from " << hlp
->id_name
<< " #" << srv
->index
+ 1 <<
882 " '" << srv
->rbuf
<< "'");
885 if (!srv
->flags
.shutdown
) {
886 helperKickQueue(hlp
);
887 } else if (!srv
->flags
.closing
&& !srv
->stats
.pending
) {
888 srv
->flags
.closing
=true;
889 srv
->writePipe
->close();
894 helperHandleRead(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
897 helper_server
*srv
= (helper_server
*)data
;
898 helper
*hlp
= srv
->parent
;
899 assert(cbdataReferenceValid(data
));
901 /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
903 if (flag
== COMM_ERR_CLOSING
) {
907 assert(conn
->fd
== srv
->readPipe
->fd
);
909 debugs(84, 5, "helperHandleRead: " << len
<< " bytes from " << hlp
->id_name
<< " #" << srv
->index
+ 1);
911 if (flag
!= COMM_OK
|| len
== 0) {
912 srv
->closePipesSafely();
917 srv
->rbuf
[srv
->roffset
] = '\0';
918 debugs(84, DBG_DATA
, Raw("accumulated", srv
->rbuf
, srv
->roffset
));
920 if (!srv
->stats
.pending
) {
921 /* someone spoke without being spoken to */
922 debugs(84, DBG_IMPORTANT
, "helperHandleRead: unexpected read from " <<
923 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << (int)len
<<
924 " bytes '" << srv
->rbuf
<< "'");
930 while ((t
= strchr(srv
->rbuf
, hlp
->eom
))) {
931 /* end of reply found */
932 char *msg
= srv
->rbuf
;
935 debugs(84, 3, "helperHandleRead: end of reply found");
937 if (t
> srv
->rbuf
&& t
[-1] == '\r' && hlp
->eom
== '\n') {
939 // rewind to the \r octet which is the real terminal now
940 // and remember that we have to skip forward 2 places now.
947 if (hlp
->childs
.concurrency
) {
948 i
= strtol(msg
, &msg
, 10);
950 while (*msg
&& xisspace(*msg
))
954 helperReturnBuffer(i
, srv
, hlp
, msg
, t
);
955 srv
->roffset
-= (t
- srv
->rbuf
) + skip
;
956 memmove(srv
->rbuf
, t
+ skip
, srv
->roffset
);
957 srv
->rbuf
[srv
->roffset
] = '\0';
960 if (Comm::IsConnOpen(srv
->readPipe
)) {
961 int spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
962 assert(spaceSize
>= 0);
964 // grow the input buffer if needed and possible
965 if (!spaceSize
&& srv
->rbuf_sz
+ 4096 <= ReadBufMaxSize
) {
966 srv
->rbuf
= (char *)memReallocBuf(srv
->rbuf
, srv
->rbuf_sz
+ 4096, &srv
->rbuf_sz
);
967 debugs(84, 3, HERE
<< "Grew read buffer to " << srv
->rbuf_sz
);
968 spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
969 assert(spaceSize
>= 0);
972 // quit reading if there is no space left
974 debugs(84, DBG_IMPORTANT
, "ERROR: Disconnecting from a " <<
975 "helper that overflowed " << srv
->rbuf_sz
<< "-byte " <<
976 "Squid input buffer: " << hlp
->id_name
<< " #" <<
978 srv
->closePipesSafely();
982 AsyncCall::Pointer call
= commCbCall(5,4, "helperHandleRead",
983 CommIoCbPtrFun(helperHandleRead
, srv
));
984 comm_read(srv
->readPipe
, srv
->rbuf
+ srv
->roffset
, spaceSize
, call
);
989 helperStatefulHandleRead(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
992 helper_stateful_server
*srv
= (helper_stateful_server
*)data
;
993 helper_stateful_request
*r
;
994 statefulhelper
*hlp
= srv
->parent
;
995 assert(cbdataReferenceValid(data
));
997 /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
999 if (flag
== COMM_ERR_CLOSING
) {
1003 assert(conn
->fd
== srv
->readPipe
->fd
);
1005 debugs(84, 5, "helperStatefulHandleRead: " << len
<< " bytes from " <<
1006 hlp
->id_name
<< " #" << srv
->index
+ 1);
1008 if (flag
!= COMM_OK
|| len
== 0) {
1009 srv
->closePipesSafely();
1013 srv
->roffset
+= len
;
1014 srv
->rbuf
[srv
->roffset
] = '\0';
1016 debugs(84, DBG_DATA
, Raw("accumulated", srv
->rbuf
, srv
->roffset
));
1019 /* someone spoke without being spoken to */
1020 debugs(84, DBG_IMPORTANT
, "helperStatefulHandleRead: unexpected read from " <<
1021 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << (int)len
<<
1022 " bytes '" << srv
->rbuf
<< "'");
1027 if ((t
= strchr(srv
->rbuf
, hlp
->eom
))) {
1028 /* end of reply found */
1031 debugs(84, 3, "helperStatefulHandleRead: end of reply found");
1033 if (t
> srv
->rbuf
&& t
[-1] == '\r' && hlp
->eom
== '\n') {
1035 // rewind to the \r octet which is the real terminal now
1036 // and remember that we have to skip forward 2 places now.
1043 if (r
&& cbdataReferenceValid(r
->data
)) {
1044 HelperReply
res(srv
->rbuf
, (t
- srv
->rbuf
));
1045 res
.whichServer
= srv
;
1046 r
->callback(r
->data
, res
);
1048 debugs(84, DBG_IMPORTANT
, "StatefulHandleRead: no callback data registered");
1051 // only skip off the \0's _after_ passing its location in HelperReply above
1054 srv
->flags
.busy
= false;
1056 * BUG: the below assumes that only one response per read() was received and discards any octets remaining.
1057 * Doing this prohibits concurrency support with multiple replies per read().
1058 * TODO: check that read() setup on these buffers pays attention to roffest!=0
1059 * TODO: check that replies bigger than the buffer are discarded and do not to affect future replies
1062 helperStatefulRequestFree(r
);
1063 srv
->request
= NULL
;
1065 -- srv
->stats
.pending
;
1066 ++ srv
->stats
.replies
;
1068 ++ hlp
->stats
.replies
;
1069 srv
->answer_time
= current_time
;
1070 hlp
->stats
.avg_svc_time
=
1071 Math::intAverage(hlp
->stats
.avg_svc_time
,
1072 tvSubMsec(srv
->dispatch_time
, current_time
),
1073 hlp
->stats
.replies
, REDIRECT_AV_FACTOR
);
1076 helperStatefulServerDone(srv
);
1078 helperStatefulReleaseServer(srv
);
1081 if (Comm::IsConnOpen(srv
->readPipe
)) {
1082 int spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
1083 assert(spaceSize
>= 0);
1085 // grow the input buffer if needed and possible
1086 if (!spaceSize
&& srv
->rbuf_sz
+ 4096 <= ReadBufMaxSize
) {
1087 srv
->rbuf
= (char *)memReallocBuf(srv
->rbuf
, srv
->rbuf_sz
+ 4096, &srv
->rbuf_sz
);
1088 debugs(84, 3, HERE
<< "Grew read buffer to " << srv
->rbuf_sz
);
1089 spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
1090 assert(spaceSize
>= 0);
1093 // quit reading if there is no space left
1095 debugs(84, DBG_IMPORTANT
, "ERROR: Disconnecting from a " <<
1096 "helper that overflowed " << srv
->rbuf_sz
<< "-byte " <<
1097 "Squid input buffer: " << hlp
->id_name
<< " #" <<
1099 srv
->closePipesSafely();
1103 AsyncCall::Pointer call
= commCbCall(5,4, "helperStatefulHandleRead",
1104 CommIoCbPtrFun(helperStatefulHandleRead
, srv
));
1105 comm_read(srv
->readPipe
, srv
->rbuf
+ srv
->roffset
, spaceSize
, call
);
1110 Enqueue(helper
* hlp
, helper_request
* r
)
1112 dlink_node
*link
= (dlink_node
*)memAllocate(MEM_DLINK_NODE
);
1113 dlinkAddTail(r
, link
, &hlp
->queue
);
1114 ++ hlp
->stats
.queue_size
;
1116 /* do this first so idle=N has a chance to grow the child pool before it hits critical. */
1117 if (hlp
->childs
.needNew() > 0) {
1118 debugs(84, DBG_CRITICAL
, "Starting new " << hlp
->id_name
<< " helpers...");
1119 helperOpenServers(hlp
);
1123 if (hlp
->stats
.queue_size
< (int)hlp
->childs
.n_running
)
1126 if (squid_curtime
- hlp
->last_queue_warn
< 600)
1129 if (shutting_down
|| reconfiguring
)
1132 hlp
->last_queue_warn
= squid_curtime
;
1134 debugs(84, DBG_CRITICAL
, "WARNING: All " << hlp
->childs
.n_active
<< "/" << hlp
->childs
.n_max
<< " " << hlp
->id_name
<< " processes are busy.");
1135 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->stats
.queue_size
<< " pending requests queued");
1136 debugs(84, DBG_CRITICAL
, "WARNING: Consider increasing the number of " << hlp
->id_name
<< " processes in your config file.");
1138 if (hlp
->stats
.queue_size
> (int)hlp
->childs
.n_running
* 2)
1139 fatalf("Too many queued %s requests", hlp
->id_name
);
1143 StatefulEnqueue(statefulhelper
* hlp
, helper_stateful_request
* r
)
1145 dlink_node
*link
= (dlink_node
*)memAllocate(MEM_DLINK_NODE
);
1146 dlinkAddTail(r
, link
, &hlp
->queue
);
1147 ++ hlp
->stats
.queue_size
;
1149 /* do this first so idle=N has a chance to grow the child pool before it hits critical. */
1150 if (hlp
->childs
.needNew() > 0) {
1151 debugs(84, DBG_CRITICAL
, "Starting new " << hlp
->id_name
<< " helpers...");
1152 helperStatefulOpenServers(hlp
);
1156 if (hlp
->stats
.queue_size
< (int)hlp
->childs
.n_running
)
1159 if (hlp
->stats
.queue_size
> (int)hlp
->childs
.n_running
* 2)
1160 fatalf("Too many queued %s requests", hlp
->id_name
);
1162 if (squid_curtime
- hlp
->last_queue_warn
< 600)
1165 if (shutting_down
|| reconfiguring
)
1168 hlp
->last_queue_warn
= squid_curtime
;
1170 debugs(84, DBG_CRITICAL
, "WARNING: All " << hlp
->childs
.n_active
<< "/" << hlp
->childs
.n_max
<< " " << hlp
->id_name
<< " processes are busy.");
1171 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->stats
.queue_size
<< " pending requests queued");
1172 debugs(84, DBG_CRITICAL
, "WARNING: Consider increasing the number of " << hlp
->id_name
<< " processes in your config file.");
1175 static helper_request
*
1176 Dequeue(helper
* hlp
)
1179 helper_request
*r
= NULL
;
1181 if ((link
= hlp
->queue
.head
)) {
1182 r
= (helper_request
*)link
->data
;
1183 dlinkDelete(link
, &hlp
->queue
);
1184 memFree(link
, MEM_DLINK_NODE
);
1185 -- hlp
->stats
.queue_size
;
1191 static helper_stateful_request
*
1192 StatefulDequeue(statefulhelper
* hlp
)
1195 helper_stateful_request
*r
= NULL
;
1197 if ((link
= hlp
->queue
.head
)) {
1198 r
= (helper_stateful_request
*)link
->data
;
1199 dlinkDelete(link
, &hlp
->queue
);
1200 memFree(link
, MEM_DLINK_NODE
);
1201 -- hlp
->stats
.queue_size
;
1207 static helper_server
*
1208 GetFirstAvailable(helper
* hlp
)
1212 helper_server
*selected
= NULL
;
1213 debugs(84, 5, "GetFirstAvailable: Running servers " << hlp
->childs
.n_running
);
1215 if (hlp
->childs
.n_running
== 0)
1218 /* Find "least" loaded helper (approx) */
1219 for (n
= hlp
->servers
.head
; n
!= NULL
; n
= n
->next
) {
1220 srv
= (helper_server
*)n
->data
;
1222 if (selected
&& selected
->stats
.pending
<= srv
->stats
.pending
)
1225 if (srv
->flags
.shutdown
)
1228 if (!srv
->stats
.pending
)
1239 /* Check for overload */
1241 debugs(84, 5, "GetFirstAvailable: None available.");
1245 if (selected
->stats
.pending
>= (hlp
->childs
.concurrency
? hlp
->childs
.concurrency
: 1)) {
1246 debugs(84, 3, "GetFirstAvailable: Least-loaded helper is overloaded!");
1250 debugs(84, 5, "GetFirstAvailable: returning srv-" << selected
->index
);
1254 static helper_stateful_server
*
1255 StatefulGetFirstAvailable(statefulhelper
* hlp
)
1258 helper_stateful_server
*srv
= NULL
;
1259 debugs(84, 5, "StatefulGetFirstAvailable: Running servers " << hlp
->childs
.n_running
);
1261 if (hlp
->childs
.n_running
== 0)
1264 for (n
= hlp
->servers
.head
; n
!= NULL
; n
= n
->next
) {
1265 srv
= (helper_stateful_server
*)n
->data
;
1267 if (srv
->flags
.busy
)
1270 if (srv
->flags
.reserved
)
1273 if (srv
->flags
.shutdown
)
1276 if ((hlp
->IsAvailable
!= NULL
) && (srv
->data
!= NULL
) && !(hlp
->IsAvailable(srv
->data
)))
1279 debugs(84, 5, "StatefulGetFirstAvailable: returning srv-" << srv
->index
);
1283 debugs(84, 5, "StatefulGetFirstAvailable: None available.");
1288 helperDispatchWriteDone(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
1290 helper_server
*srv
= (helper_server
*)data
;
1292 srv
->writebuf
->clean();
1293 delete srv
->writebuf
;
1294 srv
->writebuf
= NULL
;
1295 srv
->flags
.writing
= false;
1297 if (flag
!= COMM_OK
) {
1298 /* Helper server has crashed */
1299 debugs(84, DBG_CRITICAL
, "helperDispatch: Helper " << srv
->parent
->id_name
<< " #" << srv
->index
+ 1 << " has crashed");
1303 if (!srv
->wqueue
->isNull()) {
1304 srv
->writebuf
= srv
->wqueue
;
1305 srv
->wqueue
= new MemBuf
;
1306 srv
->flags
.writing
= true;
1307 AsyncCall::Pointer call
= commCbCall(5,5, "helperDispatchWriteDone",
1308 CommIoCbPtrFun(helperDispatchWriteDone
, srv
));
1309 Comm::Write(srv
->writePipe
, srv
->writebuf
->content(), srv
->writebuf
->contentSize(), call
, NULL
);
1314 helperDispatch(helper_server
* srv
, helper_request
* r
)
1316 helper
*hlp
= srv
->parent
;
1317 helper_request
**ptr
= NULL
;
1320 if (!cbdataReferenceValid(r
->data
)) {
1321 debugs(84, DBG_IMPORTANT
, "helperDispatch: invalid callback data");
1322 helperRequestFree(r
);
1326 for (slot
= 0; slot
< (hlp
->childs
.concurrency
? hlp
->childs
.concurrency
: 1); ++slot
) {
1327 if (!srv
->requests
[slot
]) {
1328 ptr
= &srv
->requests
[slot
];
1335 r
->dispatch_time
= current_time
;
1337 if (srv
->wqueue
->isNull())
1338 srv
->wqueue
->init();
1340 if (hlp
->childs
.concurrency
)
1341 srv
->wqueue
->Printf("%d %s", slot
, r
->buf
);
1343 srv
->wqueue
->append(r
->buf
, strlen(r
->buf
));
1345 if (!srv
->flags
.writing
) {
1346 assert(NULL
== srv
->writebuf
);
1347 srv
->writebuf
= srv
->wqueue
;
1348 srv
->wqueue
= new MemBuf
;
1349 srv
->flags
.writing
= true;
1350 AsyncCall::Pointer call
= commCbCall(5,5, "helperDispatchWriteDone",
1351 CommIoCbPtrFun(helperDispatchWriteDone
, srv
));
1352 Comm::Write(srv
->writePipe
, srv
->writebuf
->content(), srv
->writebuf
->contentSize(), call
, NULL
);
1355 debugs(84, 5, "helperDispatch: Request sent to " << hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << strlen(r
->buf
) << " bytes");
1358 ++ srv
->stats
.pending
;
1359 ++ hlp
->stats
.requests
;
1363 helperStatefulDispatchWriteDone(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
,
1364 int xerrno
, void *data
)
1370 helperStatefulDispatch(helper_stateful_server
* srv
, helper_stateful_request
* r
)
1372 statefulhelper
*hlp
= srv
->parent
;
1374 if (!cbdataReferenceValid(r
->data
)) {
1375 debugs(84, DBG_IMPORTANT
, "helperStatefulDispatch: invalid callback data");
1376 helperStatefulRequestFree(r
);
1377 helperStatefulReleaseServer(srv
);
1381 debugs(84, 9, "helperStatefulDispatch busying helper " << hlp
->id_name
<< " #" << srv
->index
+ 1);
1383 if (r
->placeholder
== 1) {
1384 /* a callback is needed before this request can _use_ a helper. */
1385 /* we don't care about releasing this helper. The request NEVER
1386 * gets to the helper. So we throw away the return code */
1387 HelperReply nilReply
;
1388 nilReply
.whichServer
= srv
;
1389 r
->callback(r
->data
, nilReply
);
1390 /* throw away the placeholder */
1391 helperStatefulRequestFree(r
);
1392 /* and push the queue. Note that the callback may have submitted a new
1393 * request to the helper which is why we test for the request */
1395 if (srv
->request
== NULL
)
1396 helperStatefulServerDone(srv
);
1401 srv
->flags
.busy
= true;
1402 srv
->flags
.reserved
= true;
1404 srv
->dispatch_time
= current_time
;
1405 AsyncCall::Pointer call
= commCbCall(5,5, "helperStatefulDispatchWriteDone",
1406 CommIoCbPtrFun(helperStatefulDispatchWriteDone
, hlp
));
1407 Comm::Write(srv
->writePipe
, r
->buf
, strlen(r
->buf
), call
, NULL
);
1408 debugs(84, 5, "helperStatefulDispatch: Request sent to " <<
1409 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " <<
1410 (int) strlen(r
->buf
) << " bytes");
1413 ++ srv
->stats
.pending
;
1414 ++ hlp
->stats
.requests
;
1418 helperKickQueue(helper
* hlp
)
1423 while ((srv
= GetFirstAvailable(hlp
)) && (r
= Dequeue(hlp
)))
1424 helperDispatch(srv
, r
);
1428 helperStatefulKickQueue(statefulhelper
* hlp
)
1430 helper_stateful_request
*r
;
1431 helper_stateful_server
*srv
;
1433 while ((srv
= StatefulGetFirstAvailable(hlp
)) && (r
= StatefulDequeue(hlp
)))
1434 helperStatefulDispatch(srv
, r
);
1438 helperStatefulServerDone(helper_stateful_server
* srv
)
1440 if (!srv
->flags
.shutdown
) {
1441 helperStatefulKickQueue(srv
->parent
);
1442 } else if (!srv
->flags
.closing
&& !srv
->flags
.reserved
&& !srv
->flags
.busy
) {
1443 srv
->closeWritePipeSafely();
1449 helperRequestFree(helper_request
* r
)
1451 cbdataReferenceDone(r
->data
);
1457 helperStatefulRequestFree(helper_stateful_request
* r
)
1460 cbdataReferenceDone(r
->data
);
1466 // TODO: should helper_ and helper_stateful_ have a common parent?
1468 helperStartStats(StoreEntry
*sentry
, void *hlp
, const char *label
)
1472 storeAppendPrintf(sentry
, "%s: unavailable\n", label
);
1477 storeAppendPrintf(sentry
, "%s:\n", label
);