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"
40 #include "format/Quoting.h"
45 #include "SquidMath.h"
46 #include "SquidTime.h"
50 #define HELPER_MAX_ARGS 64
52 /** Initial Squid input buffer size. Helper responses may exceed this, and
53 * Squid will grow the input buffer as needed, up to ReadBufMaxSize.
55 const size_t ReadBufMinSize(4*1024);
57 /** Maximum safe size of a helper-to-Squid response message plus one.
58 * Squid will warn and close the stream if a helper sends a too-big response.
59 * ssl_crtd helper is known to produce responses of at least 10KB in size.
60 * Some undocumented helpers are known to produce responses exceeding 8KB.
62 const size_t ReadBufMaxSize(32*1024);
64 static IOCB helperHandleRead
;
65 static IOCB helperStatefulHandleRead
;
66 static void helperServerFree(helper_server
*srv
);
67 static void helperStatefulServerFree(helper_stateful_server
*srv
);
68 static void Enqueue(helper
* hlp
, helper_request
*);
69 static helper_request
*Dequeue(helper
* hlp
);
70 static helper_stateful_request
*StatefulDequeue(statefulhelper
* hlp
);
71 static helper_server
*GetFirstAvailable(helper
* hlp
);
72 static helper_stateful_server
*StatefulGetFirstAvailable(statefulhelper
* hlp
);
73 static void helperDispatch(helper_server
* srv
, helper_request
* r
);
74 static void helperStatefulDispatch(helper_stateful_server
* srv
, helper_stateful_request
* r
);
75 static void helperKickQueue(helper
* hlp
);
76 static void helperStatefulKickQueue(statefulhelper
* hlp
);
77 static void helperStatefulServerDone(helper_stateful_server
* srv
);
78 static void helperRequestFree(helper_request
* r
);
79 static void helperStatefulRequestFree(helper_stateful_request
* r
);
80 static void StatefulEnqueue(statefulhelper
* hlp
, helper_stateful_request
* r
);
81 static bool helperStartStats(StoreEntry
*sentry
, void *hlp
, const char *label
);
83 CBDATA_CLASS_INIT(helper
);
84 CBDATA_CLASS_INIT(helper_server
);
85 CBDATA_CLASS_INIT(statefulhelper
);
86 CBDATA_CLASS_INIT(helper_stateful_server
);
89 HelperServerBase::initStats()
98 HelperServerBase::closePipesSafely()
103 shutdown(writePipe
->fd
, SD_BOTH
);
106 flags
.closing
= true;
107 if (readPipe
->fd
== writePipe
->fd
)
115 if (WaitForSingleObject(hIpc
, 5000) != WAIT_OBJECT_0
) {
117 debugs(84, DBG_IMPORTANT
, "WARNING: " << hlp
->id_name
<<
118 " #" << no
<< " (" << hlp
->cmdline
->key
<< "," <<
119 (long int)pid
<< ") didn't exit in 5 seconds");
127 HelperServerBase::closeWritePipeSafely()
132 shutdown(writePipe
->fd
, (readPipe
->fd
== writePipe
->fd
? SD_BOTH
: SD_SEND
));
135 flags
.closing
= true;
136 if (readPipe
->fd
== writePipe
->fd
)
142 if (WaitForSingleObject(hIpc
, 5000) != WAIT_OBJECT_0
) {
144 debugs(84, DBG_IMPORTANT
, "WARNING: " << hlp
->id_name
<<
145 " #" << no
<< " (" << hlp
->cmdline
->key
<< "," <<
146 (long int)pid
<< ") didn't exit in 5 seconds");
154 helperOpenServers(helper
* hlp
)
160 const char *args
[HELPER_MAX_ARGS
+1]; // save space for a NULL terminator
161 char fd_note_buf
[FD_DESC_SZ
];
171 if (hlp
->cmdline
== NULL
)
174 progname
= hlp
->cmdline
->key
;
176 if ((s
= strrchr(progname
, '/')))
177 shortname
= xstrdup(s
+ 1);
179 shortname
= xstrdup(progname
);
181 /* figure out how many new child are actually needed. */
182 int need_new
= hlp
->childs
.needNew();
184 debugs(84, DBG_IMPORTANT
, "helperOpenServers: Starting " << need_new
<< "/" << hlp
->childs
.n_max
<< " '" << shortname
<< "' processes");
187 debugs(84, DBG_IMPORTANT
, "helperOpenServers: No '" << shortname
<< "' processes needed.");
190 procname
= (char *)xmalloc(strlen(shortname
) + 3);
192 snprintf(procname
, strlen(shortname
) + 3, "(%s)", shortname
);
194 args
[nargs
] = procname
;
197 for (w
= hlp
->cmdline
->next
; w
&& nargs
< HELPER_MAX_ARGS
; w
= w
->next
) {
198 args
[nargs
] = w
->key
;
205 assert(nargs
<= HELPER_MAX_ARGS
);
207 for (k
= 0; k
< need_new
; ++k
) {
210 pid
= ipcCreate(hlp
->ipc_type
,
220 debugs(84, DBG_IMPORTANT
, "WARNING: Cannot run '" << progname
<< "' process.");
224 ++ hlp
->childs
.n_running
;
225 ++ hlp
->childs
.n_active
;
226 srv
= new 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 helper_stateful_server
*srv
= new helper_stateful_server
;
349 srv
->flags
.reserved
= false;
352 srv
->addr
= hlp
->addr
;
353 srv
->readPipe
= new Comm::Connection
;
354 srv
->readPipe
->fd
= rfd
;
355 srv
->writePipe
= new Comm::Connection
;
356 srv
->writePipe
->fd
= wfd
;
357 srv
->rbuf
= (char *)memAllocBuf(ReadBufMinSize
, &srv
->rbuf_sz
);
359 srv
->parent
= cbdataReference(hlp
);
361 if (hlp
->datapool
!= NULL
)
362 srv
->data
= hlp
->datapool
->alloc();
364 dlinkAddTail(srv
, &srv
->link
, &hlp
->servers
);
367 snprintf(fd_note_buf
, FD_DESC_SZ
, "%s #%d", shortname
, k
+ 1);
368 fd_note(rfd
, fd_note_buf
);
370 snprintf(fd_note_buf
, FD_DESC_SZ
, "reading %s #%d", shortname
, k
+ 1);
371 fd_note(rfd
, fd_note_buf
);
372 snprintf(fd_note_buf
, FD_DESC_SZ
, "writing %s #%d", shortname
, k
+ 1);
373 fd_note(wfd
, fd_note_buf
);
376 commSetNonBlocking(rfd
);
379 commSetNonBlocking(wfd
);
381 AsyncCall::Pointer closeCall
= asyncCall(5,4, "helperStatefulServerFree", cbdataDialer(helperStatefulServerFree
, srv
));
382 comm_add_close_handler(rfd
, closeCall
);
384 AsyncCall::Pointer call
= commCbCall(5,4, "helperStatefulHandleRead",
385 CommIoCbPtrFun(helperStatefulHandleRead
, srv
));
386 comm_read(srv
->readPipe
, srv
->rbuf
, srv
->rbuf_sz
- 1, call
);
389 hlp
->last_restart
= squid_curtime
;
390 safe_free(shortname
);
392 helperStatefulKickQueue(hlp
);
396 helperSubmit(helper
* hlp
, const char *buf
, HLPCB
* callback
, void *data
)
399 debugs(84, 3, "helperSubmit: hlp == NULL");
400 HelperReply nilReply
;
401 callback(data
, nilReply
);
405 helper_request
*r
= new helper_request
;
408 r
->callback
= callback
;
409 r
->data
= cbdataReference(data
);
410 r
->buf
= xstrdup(buf
);
412 if ((srv
= GetFirstAvailable(hlp
)))
413 helperDispatch(srv
, r
);
417 debugs(84, DBG_DATA
, Raw("buf", buf
, strlen(buf
)));
420 /// lastserver = "server last used as part of a reserved request sequence"
422 helperStatefulSubmit(statefulhelper
* hlp
, const char *buf
, HLPCB
* callback
, void *data
, helper_stateful_server
* lastserver
)
425 debugs(84, 3, "helperStatefulSubmit: hlp == NULL");
426 HelperReply nilReply
;
427 callback(data
, nilReply
);
431 helper_stateful_request
*r
= new helper_stateful_request
;
433 r
->callback
= callback
;
434 r
->data
= cbdataReference(data
);
437 r
->buf
= xstrdup(buf
);
444 if ((buf
!= NULL
) && lastserver
) {
445 debugs(84, 5, "StatefulSubmit with lastserver " << lastserver
);
446 assert(lastserver
->flags
.reserved
);
447 assert(!(lastserver
->request
));
449 debugs(84, 5, "StatefulSubmit dispatching");
450 helperStatefulDispatch(lastserver
, r
);
452 helper_stateful_server
*srv
;
453 if ((srv
= StatefulGetFirstAvailable(hlp
))) {
454 helperStatefulDispatch(srv
, r
);
456 StatefulEnqueue(hlp
, r
);
459 debugs(84, DBG_DATA
, "placeholder: '" << r
->placeholder
<<
460 "', " << Raw("buf", buf
, strlen(buf
)));
466 * helperStatefulReleaseServer tells the helper that whoever was
467 * using it no longer needs its services.
470 helperStatefulReleaseServer(helper_stateful_server
* srv
)
472 debugs(84, 3, HERE
<< "srv-" << srv
->index
<< " flags.reserved = " << srv
->flags
.reserved
);
473 if (!srv
->flags
.reserved
)
476 ++ srv
->stats
.releases
;
478 srv
->flags
.reserved
= false;
479 if (srv
->parent
->OnEmptyQueue
!= NULL
&& srv
->data
)
480 srv
->parent
->OnEmptyQueue(srv
->data
);
482 helperStatefulServerDone(srv
);
485 /** return a pointer to the stateful routines data area */
487 helperStatefulServerGetData(helper_stateful_server
* srv
)
493 * Dump some stats about the helper states to a StoreEntry
496 helperStats(StoreEntry
* sentry
, helper
* hlp
, const char *label
)
498 if (!helperStartStats(sentry
, hlp
, label
))
501 storeAppendPrintf(sentry
, "program: %s\n",
503 storeAppendPrintf(sentry
, "number active: %d of %d (%d shutting down)\n",
504 hlp
->childs
.n_active
, hlp
->childs
.n_max
, (hlp
->childs
.n_running
- hlp
->childs
.n_active
) );
505 storeAppendPrintf(sentry
, "requests sent: %d\n",
506 hlp
->stats
.requests
);
507 storeAppendPrintf(sentry
, "replies received: %d\n",
509 storeAppendPrintf(sentry
, "queue length: %d\n",
510 hlp
->stats
.queue_size
);
511 storeAppendPrintf(sentry
, "avg service time: %d msec\n",
512 hlp
->stats
.avg_svc_time
);
513 storeAppendPrintf(sentry
, "\n");
514 storeAppendPrintf(sentry
, "%7s\t%7s\t%7s\t%11s\t%11s\t%s\t%7s\t%7s\t%7s\n",
525 for (dlink_node
*link
= hlp
->servers
.head
; link
; link
= link
->next
) {
526 helper_server
*srv
= (helper_server
*)link
->data
;
527 double tt
= 0.001 * (srv
->requests
[0] ? tvSubMsec(srv
->requests
[0]->dispatch_time
, current_time
) : tvSubMsec(srv
->dispatch_time
, srv
->answer_time
));
528 storeAppendPrintf(sentry
, "%7d\t%7d\t%7d\t%11" PRIu64
"\t%11" PRIu64
"\t%c%c%c%c\t%7.3f\t%7d\t%s\n",
534 srv
->stats
.pending
? 'B' : ' ',
535 srv
->flags
.writing
? 'W' : ' ',
536 srv
->flags
.closing
? 'C' : ' ',
537 srv
->flags
.shutdown
? 'S' : ' ',
540 srv
->requests
[0] ? Format::QuoteMimeBlob(srv
->requests
[0]->buf
) : "(none)");
543 storeAppendPrintf(sentry
, "\nFlags key:\n\n");
544 storeAppendPrintf(sentry
, " B = BUSY\n");
545 storeAppendPrintf(sentry
, " W = WRITING\n");
546 storeAppendPrintf(sentry
, " C = CLOSING\n");
547 storeAppendPrintf(sentry
, " S = SHUTDOWN PENDING\n");
551 helperStatefulStats(StoreEntry
* sentry
, statefulhelper
* hlp
, const char *label
)
553 if (!helperStartStats(sentry
, hlp
, label
))
556 storeAppendPrintf(sentry
, "program: %s\n",
558 storeAppendPrintf(sentry
, "number active: %d of %d (%d shutting down)\n",
559 hlp
->childs
.n_active
, hlp
->childs
.n_max
, (hlp
->childs
.n_running
- hlp
->childs
.n_active
) );
560 storeAppendPrintf(sentry
, "requests sent: %d\n",
561 hlp
->stats
.requests
);
562 storeAppendPrintf(sentry
, "replies received: %d\n",
564 storeAppendPrintf(sentry
, "queue length: %d\n",
565 hlp
->stats
.queue_size
);
566 storeAppendPrintf(sentry
, "avg service time: %d msec\n",
567 hlp
->stats
.avg_svc_time
);
568 storeAppendPrintf(sentry
, "\n");
569 storeAppendPrintf(sentry
, "%7s\t%7s\t%7s\t%11s\t%11s\t%6s\t%7s\t%7s\t%7s\n",
580 for (dlink_node
*link
= hlp
->servers
.head
; link
; link
= link
->next
) {
581 helper_stateful_server
*srv
= (helper_stateful_server
*)link
->data
;
582 double tt
= 0.001 * tvSubMsec(srv
->dispatch_time
, srv
->flags
.busy
? current_time
: srv
->answer_time
);
583 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",
589 srv
->flags
.busy
? 'B' : ' ',
590 srv
->flags
.closing
? 'C' : ' ',
591 srv
->flags
.reserved
? 'R' : ' ',
592 srv
->flags
.shutdown
? 'S' : ' ',
593 srv
->request
? (srv
->request
->placeholder
? 'P' : ' ') : ' ',
596 srv
->request
? Format::QuoteMimeBlob(srv
->request
->buf
) : "(none)");
599 storeAppendPrintf(sentry
, "\nFlags key:\n\n");
600 storeAppendPrintf(sentry
, " B = BUSY\n");
601 storeAppendPrintf(sentry
, " C = CLOSING\n");
602 storeAppendPrintf(sentry
, " R = RESERVED\n");
603 storeAppendPrintf(sentry
, " S = SHUTDOWN PENDING\n");
604 storeAppendPrintf(sentry
, " P = PLACEHOLDER\n");
608 helperShutdown(helper
* hlp
)
610 dlink_node
*link
= hlp
->servers
.head
;
614 srv
= (helper_server
*)link
->data
;
617 if (srv
->flags
.shutdown
) {
618 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " has already SHUT DOWN.");
622 assert(hlp
->childs
.n_active
> 0);
623 -- hlp
->childs
.n_active
;
624 srv
->flags
.shutdown
= true; /* request it to shut itself down */
626 if (srv
->flags
.closing
) {
627 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is CLOSING.");
631 if (srv
->stats
.pending
) {
632 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is BUSY.");
636 debugs(84, 3, "helperShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " shutting down.");
637 /* the rest of the details is dealt with in the helperServerFree
640 srv
->closePipesSafely();
645 helperStatefulShutdown(statefulhelper
* hlp
)
647 dlink_node
*link
= hlp
->servers
.head
;
648 helper_stateful_server
*srv
;
651 srv
= (helper_stateful_server
*)link
->data
;
654 if (srv
->flags
.shutdown
) {
655 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " has already SHUT DOWN.");
659 assert(hlp
->childs
.n_active
> 0);
660 -- hlp
->childs
.n_active
;
661 srv
->flags
.shutdown
= true; /* request it to shut itself down */
663 if (srv
->flags
.busy
) {
664 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is BUSY.");
668 if (srv
->flags
.closing
) {
669 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is CLOSING.");
673 if (srv
->flags
.reserved
) {
675 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is RESERVED. Closing anyway.");
677 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " is RESERVED. Not Shutting Down Yet.");
682 debugs(84, 3, "helperStatefulShutdown: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " shutting down.");
684 /* the rest of the details is dealt with in the helperStatefulServerFree
687 srv
->closePipesSafely();
693 /* note, don't free id_name, it probably points to static memory */
696 debugs(84, DBG_CRITICAL
, "WARNING: freeing " << id_name
<< " helper with " << stats
.queue_size
<< " requests queued");
699 /* ====================================================================== */
700 /* LOCAL FUNCTIONS */
701 /* ====================================================================== */
704 helperServerFree(helper_server
*srv
)
706 helper
*hlp
= srv
->parent
;
708 int i
, concurrency
= hlp
->childs
.concurrency
;
714 memFreeBuf(srv
->rbuf_sz
, srv
->rbuf
);
718 srv
->wqueue
->clean();
722 srv
->writebuf
->clean();
723 delete srv
->writebuf
;
724 srv
->writebuf
= NULL
;
727 if (Comm::IsConnOpen(srv
->writePipe
))
728 srv
->closeWritePipeSafely();
730 dlinkDelete(&srv
->link
, &hlp
->servers
);
732 assert(hlp
->childs
.n_running
> 0);
733 -- hlp
->childs
.n_running
;
735 if (!srv
->flags
.shutdown
) {
736 assert(hlp
->childs
.n_active
> 0);
737 -- hlp
->childs
.n_active
;
738 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " exited");
740 if (hlp
->childs
.needNew() > 0) {
741 debugs(80, DBG_IMPORTANT
, "Too few " << hlp
->id_name
<< " processes are running (need " << hlp
->childs
.needNew() << "/" << hlp
->childs
.n_max
<< ")");
743 if (hlp
->childs
.n_active
< hlp
->childs
.n_startup
&& hlp
->last_restart
> squid_curtime
- 30) {
744 if (srv
->stats
.replies
< 1)
745 fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp
->id_name
);
747 debugs(80, DBG_CRITICAL
, "ERROR: The " << hlp
->id_name
<< " helpers are crashing too rapidly, need help!");
750 debugs(80, DBG_IMPORTANT
, "Starting new helpers");
751 helperOpenServers(hlp
);
755 for (i
= 0; i
< concurrency
; ++i
) {
756 // XXX: re-schedule these on another helper?
757 if ((r
= srv
->requests
[i
])) {
760 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
761 HelperReply nilReply
;
762 r
->callback(cbdata
, nilReply
);
765 helperRequestFree(r
);
767 srv
->requests
[i
] = NULL
;
770 safe_free(srv
->requests
);
772 cbdataReferenceDone(srv
->parent
);
777 helperStatefulServerFree(helper_stateful_server
*srv
)
779 statefulhelper
*hlp
= srv
->parent
;
780 helper_stateful_request
*r
;
783 memFreeBuf(srv
->rbuf_sz
, srv
->rbuf
);
788 srv
->wqueue
->clean();
794 /* TODO: walk the local queue of requests and carry them all out */
795 if (Comm::IsConnOpen(srv
->writePipe
))
796 srv
->closeWritePipeSafely();
798 dlinkDelete(&srv
->link
, &hlp
->servers
);
800 assert(hlp
->childs
.n_running
> 0);
801 -- hlp
->childs
.n_running
;
803 if (!srv
->flags
.shutdown
) {
804 assert( hlp
->childs
.n_active
> 0);
805 -- hlp
->childs
.n_active
;
806 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->id_name
<< " #" << srv
->index
+ 1 << " exited");
808 if (hlp
->childs
.needNew() > 0) {
809 debugs(80, DBG_IMPORTANT
, "Too few " << hlp
->id_name
<< " processes are running (need " << hlp
->childs
.needNew() << "/" << hlp
->childs
.n_max
<< ")");
811 if (hlp
->childs
.n_active
< hlp
->childs
.n_startup
&& hlp
->last_restart
> squid_curtime
- 30) {
812 if (srv
->stats
.replies
< 1)
813 fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp
->id_name
);
815 debugs(80, DBG_CRITICAL
, "ERROR: The " << hlp
->id_name
<< " helpers are crashing too rapidly, need help!");
818 debugs(80, DBG_IMPORTANT
, "Starting new helpers");
819 helperStatefulOpenServers(hlp
);
823 if ((r
= srv
->request
)) {
826 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
827 HelperReply nilReply
;
828 nilReply
.whichServer
= srv
;
829 r
->callback(cbdata
, nilReply
);
832 helperStatefulRequestFree(r
);
837 if (srv
->data
!= NULL
)
838 hlp
->datapool
->freeOne(srv
->data
);
840 cbdataReferenceDone(srv
->parent
);
845 /// Calls back with a pointer to the buffer with the helper output
847 helperReturnBuffer(int request_number
, helper_server
* srv
, helper
* hlp
, char * msg
, char * msg_end
)
849 helper_request
*r
= srv
->requests
[request_number
];
851 HLPCB
*callback
= r
->callback
;
853 srv
->requests
[request_number
] = NULL
;
858 if (cbdataReferenceValidDone(r
->data
, &cbdata
)) {
859 HelperReply
response(msg
, (msg_end
-msg
));
860 callback(cbdata
, response
);
863 -- srv
->stats
.pending
;
864 ++ srv
->stats
.replies
;
866 ++ hlp
->stats
.replies
;
868 srv
->answer_time
= current_time
;
870 srv
->dispatch_time
= r
->dispatch_time
;
872 hlp
->stats
.avg_svc_time
=
873 Math::intAverage(hlp
->stats
.avg_svc_time
,
874 tvSubMsec(r
->dispatch_time
, current_time
),
875 hlp
->stats
.replies
, REDIRECT_AV_FACTOR
);
877 helperRequestFree(r
);
879 debugs(84, DBG_IMPORTANT
, "helperHandleRead: unexpected reply on channel " <<
880 request_number
<< " from " << hlp
->id_name
<< " #" << srv
->index
+ 1 <<
881 " '" << srv
->rbuf
<< "'");
884 if (!srv
->flags
.shutdown
) {
885 helperKickQueue(hlp
);
886 } else if (!srv
->flags
.closing
&& !srv
->stats
.pending
) {
887 srv
->flags
.closing
=true;
888 srv
->writePipe
->close();
893 helperHandleRead(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
896 helper_server
*srv
= (helper_server
*)data
;
897 helper
*hlp
= srv
->parent
;
898 assert(cbdataReferenceValid(data
));
900 /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
902 if (flag
== COMM_ERR_CLOSING
) {
906 assert(conn
->fd
== srv
->readPipe
->fd
);
908 debugs(84, 5, "helperHandleRead: " << len
<< " bytes from " << hlp
->id_name
<< " #" << srv
->index
+ 1);
910 if (flag
!= COMM_OK
|| len
== 0) {
911 srv
->closePipesSafely();
916 srv
->rbuf
[srv
->roffset
] = '\0';
917 debugs(84, DBG_DATA
, Raw("accumulated", srv
->rbuf
, srv
->roffset
));
919 if (!srv
->stats
.pending
) {
920 /* someone spoke without being spoken to */
921 debugs(84, DBG_IMPORTANT
, "helperHandleRead: unexpected read from " <<
922 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << (int)len
<<
923 " bytes '" << srv
->rbuf
<< "'");
929 while ((t
= strchr(srv
->rbuf
, hlp
->eom
))) {
930 /* end of reply found */
931 char *msg
= srv
->rbuf
;
934 debugs(84, 3, "helperHandleRead: end of reply found");
936 if (t
> srv
->rbuf
&& t
[-1] == '\r' && hlp
->eom
== '\n') {
938 // rewind to the \r octet which is the real terminal now
939 // and remember that we have to skip forward 2 places now.
946 if (hlp
->childs
.concurrency
) {
947 i
= strtol(msg
, &msg
, 10);
949 while (*msg
&& xisspace(*msg
))
953 helperReturnBuffer(i
, srv
, hlp
, msg
, t
);
954 srv
->roffset
-= (t
- srv
->rbuf
) + skip
;
955 memmove(srv
->rbuf
, t
+ skip
, srv
->roffset
);
956 srv
->rbuf
[srv
->roffset
] = '\0';
959 if (Comm::IsConnOpen(srv
->readPipe
) && !fd_table
[srv
->readPipe
->fd
].closing()) {
960 int spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
961 assert(spaceSize
>= 0);
963 // grow the input buffer if needed and possible
964 if (!spaceSize
&& srv
->rbuf_sz
+ 4096 <= ReadBufMaxSize
) {
965 srv
->rbuf
= (char *)memReallocBuf(srv
->rbuf
, srv
->rbuf_sz
+ 4096, &srv
->rbuf_sz
);
966 debugs(84, 3, HERE
<< "Grew read buffer to " << srv
->rbuf_sz
);
967 spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
968 assert(spaceSize
>= 0);
971 // quit reading if there is no space left
973 debugs(84, DBG_IMPORTANT
, "ERROR: Disconnecting from a " <<
974 "helper that overflowed " << srv
->rbuf_sz
<< "-byte " <<
975 "Squid input buffer: " << hlp
->id_name
<< " #" <<
977 srv
->closePipesSafely();
981 AsyncCall::Pointer call
= commCbCall(5,4, "helperHandleRead",
982 CommIoCbPtrFun(helperHandleRead
, srv
));
983 comm_read(srv
->readPipe
, srv
->rbuf
+ srv
->roffset
, spaceSize
, call
);
988 helperStatefulHandleRead(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
991 helper_stateful_server
*srv
= (helper_stateful_server
*)data
;
992 helper_stateful_request
*r
;
993 statefulhelper
*hlp
= srv
->parent
;
994 assert(cbdataReferenceValid(data
));
996 /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */
998 if (flag
== COMM_ERR_CLOSING
) {
1002 assert(conn
->fd
== srv
->readPipe
->fd
);
1004 debugs(84, 5, "helperStatefulHandleRead: " << len
<< " bytes from " <<
1005 hlp
->id_name
<< " #" << srv
->index
+ 1);
1007 if (flag
!= COMM_OK
|| len
== 0) {
1008 srv
->closePipesSafely();
1012 srv
->roffset
+= len
;
1013 srv
->rbuf
[srv
->roffset
] = '\0';
1015 debugs(84, DBG_DATA
, Raw("accumulated", srv
->rbuf
, srv
->roffset
));
1018 /* someone spoke without being spoken to */
1019 debugs(84, DBG_IMPORTANT
, "helperStatefulHandleRead: unexpected read from " <<
1020 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << (int)len
<<
1021 " bytes '" << srv
->rbuf
<< "'");
1026 if ((t
= strchr(srv
->rbuf
, hlp
->eom
))) {
1027 /* end of reply found */
1030 debugs(84, 3, "helperStatefulHandleRead: end of reply found");
1032 if (t
> srv
->rbuf
&& t
[-1] == '\r' && hlp
->eom
== '\n') {
1034 // rewind to the \r octet which is the real terminal now
1035 // and remember that we have to skip forward 2 places now.
1042 if (r
&& cbdataReferenceValid(r
->data
)) {
1043 HelperReply
res(srv
->rbuf
, (t
- srv
->rbuf
));
1044 res
.whichServer
= srv
;
1045 r
->callback(r
->data
, res
);
1047 debugs(84, DBG_IMPORTANT
, "StatefulHandleRead: no callback data registered");
1050 // only skip off the \0's _after_ passing its location in HelperReply above
1053 srv
->flags
.busy
= false;
1055 * BUG: the below assumes that only one response per read() was received and discards any octets remaining.
1056 * Doing this prohibits concurrency support with multiple replies per read().
1057 * TODO: check that read() setup on these buffers pays attention to roffest!=0
1058 * TODO: check that replies bigger than the buffer are discarded and do not to affect future replies
1061 helperStatefulRequestFree(r
);
1062 srv
->request
= NULL
;
1064 -- srv
->stats
.pending
;
1065 ++ srv
->stats
.replies
;
1067 ++ hlp
->stats
.replies
;
1068 srv
->answer_time
= current_time
;
1069 hlp
->stats
.avg_svc_time
=
1070 Math::intAverage(hlp
->stats
.avg_svc_time
,
1071 tvSubMsec(srv
->dispatch_time
, current_time
),
1072 hlp
->stats
.replies
, REDIRECT_AV_FACTOR
);
1075 helperStatefulServerDone(srv
);
1077 helperStatefulReleaseServer(srv
);
1080 if (Comm::IsConnOpen(srv
->readPipe
) && !fd_table
[srv
->readPipe
->fd
].closing()) {
1081 int spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
1082 assert(spaceSize
>= 0);
1084 // grow the input buffer if needed and possible
1085 if (!spaceSize
&& srv
->rbuf_sz
+ 4096 <= ReadBufMaxSize
) {
1086 srv
->rbuf
= (char *)memReallocBuf(srv
->rbuf
, srv
->rbuf_sz
+ 4096, &srv
->rbuf_sz
);
1087 debugs(84, 3, HERE
<< "Grew read buffer to " << srv
->rbuf_sz
);
1088 spaceSize
= srv
->rbuf_sz
- srv
->roffset
- 1;
1089 assert(spaceSize
>= 0);
1092 // quit reading if there is no space left
1094 debugs(84, DBG_IMPORTANT
, "ERROR: Disconnecting from a " <<
1095 "helper that overflowed " << srv
->rbuf_sz
<< "-byte " <<
1096 "Squid input buffer: " << hlp
->id_name
<< " #" <<
1098 srv
->closePipesSafely();
1102 AsyncCall::Pointer call
= commCbCall(5,4, "helperStatefulHandleRead",
1103 CommIoCbPtrFun(helperStatefulHandleRead
, srv
));
1104 comm_read(srv
->readPipe
, srv
->rbuf
+ srv
->roffset
, spaceSize
, call
);
1109 Enqueue(helper
* hlp
, helper_request
* r
)
1111 dlink_node
*link
= (dlink_node
*)memAllocate(MEM_DLINK_NODE
);
1112 dlinkAddTail(r
, link
, &hlp
->queue
);
1113 ++ hlp
->stats
.queue_size
;
1115 /* do this first so idle=N has a chance to grow the child pool before it hits critical. */
1116 if (hlp
->childs
.needNew() > 0) {
1117 debugs(84, DBG_CRITICAL
, "Starting new " << hlp
->id_name
<< " helpers...");
1118 helperOpenServers(hlp
);
1122 if (hlp
->stats
.queue_size
< (int)hlp
->childs
.n_running
)
1125 if (squid_curtime
- hlp
->last_queue_warn
< 600)
1128 if (shutting_down
|| reconfiguring
)
1131 hlp
->last_queue_warn
= squid_curtime
;
1133 debugs(84, DBG_CRITICAL
, "WARNING: All " << hlp
->childs
.n_active
<< "/" << hlp
->childs
.n_max
<< " " << hlp
->id_name
<< " processes are busy.");
1134 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->stats
.queue_size
<< " pending requests queued");
1135 debugs(84, DBG_CRITICAL
, "WARNING: Consider increasing the number of " << hlp
->id_name
<< " processes in your config file.");
1137 if (hlp
->stats
.queue_size
> (int)hlp
->childs
.n_running
* 2)
1138 fatalf("Too many queued %s requests", hlp
->id_name
);
1142 StatefulEnqueue(statefulhelper
* hlp
, helper_stateful_request
* r
)
1144 dlink_node
*link
= (dlink_node
*)memAllocate(MEM_DLINK_NODE
);
1145 dlinkAddTail(r
, link
, &hlp
->queue
);
1146 ++ hlp
->stats
.queue_size
;
1148 /* do this first so idle=N has a chance to grow the child pool before it hits critical. */
1149 if (hlp
->childs
.needNew() > 0) {
1150 debugs(84, DBG_CRITICAL
, "Starting new " << hlp
->id_name
<< " helpers...");
1151 helperStatefulOpenServers(hlp
);
1155 if (hlp
->stats
.queue_size
< (int)hlp
->childs
.n_running
)
1158 if (hlp
->stats
.queue_size
> (int)hlp
->childs
.n_running
* 2)
1159 fatalf("Too many queued %s requests", hlp
->id_name
);
1161 if (squid_curtime
- hlp
->last_queue_warn
< 600)
1164 if (shutting_down
|| reconfiguring
)
1167 hlp
->last_queue_warn
= squid_curtime
;
1169 debugs(84, DBG_CRITICAL
, "WARNING: All " << hlp
->childs
.n_active
<< "/" << hlp
->childs
.n_max
<< " " << hlp
->id_name
<< " processes are busy.");
1170 debugs(84, DBG_CRITICAL
, "WARNING: " << hlp
->stats
.queue_size
<< " pending requests queued");
1171 debugs(84, DBG_CRITICAL
, "WARNING: Consider increasing the number of " << hlp
->id_name
<< " processes in your config file.");
1174 static helper_request
*
1175 Dequeue(helper
* hlp
)
1178 helper_request
*r
= NULL
;
1180 if ((link
= hlp
->queue
.head
)) {
1181 r
= (helper_request
*)link
->data
;
1182 dlinkDelete(link
, &hlp
->queue
);
1183 memFree(link
, MEM_DLINK_NODE
);
1184 -- hlp
->stats
.queue_size
;
1190 static helper_stateful_request
*
1191 StatefulDequeue(statefulhelper
* hlp
)
1194 helper_stateful_request
*r
= NULL
;
1196 if ((link
= hlp
->queue
.head
)) {
1197 r
= (helper_stateful_request
*)link
->data
;
1198 dlinkDelete(link
, &hlp
->queue
);
1199 memFree(link
, MEM_DLINK_NODE
);
1200 -- hlp
->stats
.queue_size
;
1206 static helper_server
*
1207 GetFirstAvailable(helper
* hlp
)
1211 helper_server
*selected
= NULL
;
1212 debugs(84, 5, "GetFirstAvailable: Running servers " << hlp
->childs
.n_running
);
1214 if (hlp
->childs
.n_running
== 0)
1217 /* Find "least" loaded helper (approx) */
1218 for (n
= hlp
->servers
.head
; n
!= NULL
; n
= n
->next
) {
1219 srv
= (helper_server
*)n
->data
;
1221 if (selected
&& selected
->stats
.pending
<= srv
->stats
.pending
)
1224 if (srv
->flags
.shutdown
)
1227 if (!srv
->stats
.pending
)
1238 /* Check for overload */
1240 debugs(84, 5, "GetFirstAvailable: None available.");
1244 if (selected
->stats
.pending
>= (hlp
->childs
.concurrency
? hlp
->childs
.concurrency
: 1)) {
1245 debugs(84, 3, "GetFirstAvailable: Least-loaded helper is overloaded!");
1249 debugs(84, 5, "GetFirstAvailable: returning srv-" << selected
->index
);
1253 static helper_stateful_server
*
1254 StatefulGetFirstAvailable(statefulhelper
* hlp
)
1257 helper_stateful_server
*srv
= NULL
;
1258 debugs(84, 5, "StatefulGetFirstAvailable: Running servers " << hlp
->childs
.n_running
);
1260 if (hlp
->childs
.n_running
== 0)
1263 for (n
= hlp
->servers
.head
; n
!= NULL
; n
= n
->next
) {
1264 srv
= (helper_stateful_server
*)n
->data
;
1266 if (srv
->flags
.busy
)
1269 if (srv
->flags
.reserved
)
1272 if (srv
->flags
.shutdown
)
1275 if ((hlp
->IsAvailable
!= NULL
) && (srv
->data
!= NULL
) && !(hlp
->IsAvailable(srv
->data
)))
1278 debugs(84, 5, "StatefulGetFirstAvailable: returning srv-" << srv
->index
);
1282 debugs(84, 5, "StatefulGetFirstAvailable: None available.");
1287 helperDispatchWriteDone(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
, int xerrno
, void *data
)
1289 helper_server
*srv
= (helper_server
*)data
;
1291 srv
->writebuf
->clean();
1292 delete srv
->writebuf
;
1293 srv
->writebuf
= NULL
;
1294 srv
->flags
.writing
= false;
1296 if (flag
!= COMM_OK
) {
1297 /* Helper server has crashed */
1298 debugs(84, DBG_CRITICAL
, "helperDispatch: Helper " << srv
->parent
->id_name
<< " #" << srv
->index
+ 1 << " has crashed");
1302 if (!srv
->wqueue
->isNull()) {
1303 srv
->writebuf
= srv
->wqueue
;
1304 srv
->wqueue
= new MemBuf
;
1305 srv
->flags
.writing
= true;
1306 AsyncCall::Pointer call
= commCbCall(5,5, "helperDispatchWriteDone",
1307 CommIoCbPtrFun(helperDispatchWriteDone
, srv
));
1308 Comm::Write(srv
->writePipe
, srv
->writebuf
->content(), srv
->writebuf
->contentSize(), call
, NULL
);
1313 helperDispatch(helper_server
* srv
, helper_request
* r
)
1315 helper
*hlp
= srv
->parent
;
1316 helper_request
**ptr
= NULL
;
1319 if (!cbdataReferenceValid(r
->data
)) {
1320 debugs(84, DBG_IMPORTANT
, "helperDispatch: invalid callback data");
1321 helperRequestFree(r
);
1325 for (slot
= 0; slot
< (hlp
->childs
.concurrency
? hlp
->childs
.concurrency
: 1); ++slot
) {
1326 if (!srv
->requests
[slot
]) {
1327 ptr
= &srv
->requests
[slot
];
1334 r
->dispatch_time
= current_time
;
1336 if (srv
->wqueue
->isNull())
1337 srv
->wqueue
->init();
1339 if (hlp
->childs
.concurrency
)
1340 srv
->wqueue
->Printf("%d %s", slot
, r
->buf
);
1342 srv
->wqueue
->append(r
->buf
, strlen(r
->buf
));
1344 if (!srv
->flags
.writing
) {
1345 assert(NULL
== srv
->writebuf
);
1346 srv
->writebuf
= srv
->wqueue
;
1347 srv
->wqueue
= new MemBuf
;
1348 srv
->flags
.writing
= true;
1349 AsyncCall::Pointer call
= commCbCall(5,5, "helperDispatchWriteDone",
1350 CommIoCbPtrFun(helperDispatchWriteDone
, srv
));
1351 Comm::Write(srv
->writePipe
, srv
->writebuf
->content(), srv
->writebuf
->contentSize(), call
, NULL
);
1354 debugs(84, 5, "helperDispatch: Request sent to " << hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " << strlen(r
->buf
) << " bytes");
1357 ++ srv
->stats
.pending
;
1358 ++ hlp
->stats
.requests
;
1362 helperStatefulDispatchWriteDone(const Comm::ConnectionPointer
&conn
, char *buf
, size_t len
, comm_err_t flag
,
1363 int xerrno
, void *data
)
1369 helperStatefulDispatch(helper_stateful_server
* srv
, helper_stateful_request
* r
)
1371 statefulhelper
*hlp
= srv
->parent
;
1373 if (!cbdataReferenceValid(r
->data
)) {
1374 debugs(84, DBG_IMPORTANT
, "helperStatefulDispatch: invalid callback data");
1375 helperStatefulRequestFree(r
);
1376 helperStatefulReleaseServer(srv
);
1380 debugs(84, 9, "helperStatefulDispatch busying helper " << hlp
->id_name
<< " #" << srv
->index
+ 1);
1382 if (r
->placeholder
== 1) {
1383 /* a callback is needed before this request can _use_ a helper. */
1384 /* we don't care about releasing this helper. The request NEVER
1385 * gets to the helper. So we throw away the return code */
1386 HelperReply nilReply
;
1387 nilReply
.whichServer
= srv
;
1388 r
->callback(r
->data
, nilReply
);
1389 /* throw away the placeholder */
1390 helperStatefulRequestFree(r
);
1391 /* and push the queue. Note that the callback may have submitted a new
1392 * request to the helper which is why we test for the request */
1394 if (srv
->request
== NULL
)
1395 helperStatefulServerDone(srv
);
1400 srv
->flags
.busy
= true;
1401 srv
->flags
.reserved
= true;
1403 srv
->dispatch_time
= current_time
;
1404 AsyncCall::Pointer call
= commCbCall(5,5, "helperStatefulDispatchWriteDone",
1405 CommIoCbPtrFun(helperStatefulDispatchWriteDone
, hlp
));
1406 Comm::Write(srv
->writePipe
, r
->buf
, strlen(r
->buf
), call
, NULL
);
1407 debugs(84, 5, "helperStatefulDispatch: Request sent to " <<
1408 hlp
->id_name
<< " #" << srv
->index
+ 1 << ", " <<
1409 (int) strlen(r
->buf
) << " bytes");
1412 ++ srv
->stats
.pending
;
1413 ++ hlp
->stats
.requests
;
1417 helperKickQueue(helper
* hlp
)
1422 while ((srv
= GetFirstAvailable(hlp
)) && (r
= Dequeue(hlp
)))
1423 helperDispatch(srv
, r
);
1427 helperStatefulKickQueue(statefulhelper
* hlp
)
1429 helper_stateful_request
*r
;
1430 helper_stateful_server
*srv
;
1432 while ((srv
= StatefulGetFirstAvailable(hlp
)) && (r
= StatefulDequeue(hlp
)))
1433 helperStatefulDispatch(srv
, r
);
1437 helperStatefulServerDone(helper_stateful_server
* srv
)
1439 if (!srv
->flags
.shutdown
) {
1440 helperStatefulKickQueue(srv
->parent
);
1441 } else if (!srv
->flags
.closing
&& !srv
->flags
.reserved
&& !srv
->flags
.busy
) {
1442 srv
->closeWritePipeSafely();
1448 helperRequestFree(helper_request
* r
)
1450 cbdataReferenceDone(r
->data
);
1456 helperStatefulRequestFree(helper_stateful_request
* r
)
1459 cbdataReferenceDone(r
->data
);
1465 // TODO: should helper_ and helper_stateful_ have a common parent?
1467 helperStartStats(StoreEntry
*sentry
, void *hlp
, const char *label
)
1471 storeAppendPrintf(sentry
, "%s: unavailable\n", label
);
1476 storeAppendPrintf(sentry
, "%s:\n", label
);