CBDATA_CLASS_INIT(statefulhelper);
CBDATA_CLASS_INIT(helper_stateful_server);
+InstanceIdDefinitions(HelperServerBase, "Hlpr");
+
void
HelperServerBase::initStats()
{
HelperServerBase::closePipesSafely()
{
#if _SQUID_WINDOWS_
- int no = index + 1;
-
shutdown(writePipe->fd, SD_BOTH);
#endif
if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
getCurrentTime();
debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
- " #" << no << " (" << hlp->cmdline->key << "," <<
+ " #" << index << " (" << hlp->cmdline->key << "," <<
(long int)pid << ") didn't exit in 5 seconds");
}
CloseHandle(hIpc);
HelperServerBase::closeWritePipeSafely()
{
#if _SQUID_WINDOWS_
- int no = index + 1;
-
shutdown(writePipe->fd, (readPipe->fd == writePipe->fd ? SD_BOTH : SD_SEND));
#endif
if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) {
getCurrentTime();
debugs(84, DBG_IMPORTANT, "WARNING: " << hlp->id_name <<
- " #" << no << " (" << hlp->cmdline->key << "," <<
+ " #" << index << " (" << hlp->cmdline->key << "," <<
(long int)pid << ") didn't exit in 5 seconds");
}
CloseHandle(hIpc);
srv->hIpc = hIpc;
srv->pid = pid;
srv->initStats();
- srv->index = k;
srv->addr = hlp->addr;
srv->readPipe = new Comm::Connection;
srv->readPipe->fd = rfd;
srv->pid = pid;
srv->flags.reserved = false;
srv->initStats();
- srv->index = k;
srv->addr = hlp->addr;
srv->readPipe = new Comm::Connection;
srv->readPipe->fd = rfd;
hlp->stats.avg_svc_time);
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "%7s\t%7s\t%7s\t%11s\t%11s\t%s\t%7s\t%7s\t%7s\n",
- "#",
+ "ID #",
"FD",
"PID",
"# Requests",
for (dlink_node *link = hlp->servers.head; link; link = link->next) {
helper_server *srv = (helper_server*)link->data;
double tt = 0.001 * (srv->requests[0] ? tvSubMsec(srv->requests[0]->dispatch_time, current_time) : tvSubMsec(srv->dispatch_time, srv->answer_time));
- 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",
- srv->index + 1,
+ storeAppendPrintf(sentry, "%7u\t%7d\t%7d\t%11" PRIu64 "\t%11" PRIu64 "\t%c%c%c%c\t%7.3f\t%7d\t%s\n",
+ srv->index.value,
srv->readPipe->fd,
srv->pid,
srv->stats.uses,
hlp->stats.avg_svc_time);
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "%7s\t%7s\t%7s\t%11s\t%11s\t%6s\t%7s\t%7s\t%7s\n",
- "#",
+ "ID #",
"FD",
"PID",
"# Requests",
for (dlink_node *link = hlp->servers.head; link; link = link->next) {
helper_stateful_server *srv = (helper_stateful_server *)link->data;
double tt = 0.001 * tvSubMsec(srv->dispatch_time, srv->flags.busy ? current_time : srv->answer_time);
- 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",
- srv->index + 1,
+ storeAppendPrintf(sentry, "%7u\t%7d\t%7d\t%11" PRIu64 "\t%11" PRIu64 "\t%c%c%c%c%c\t%7.3f\t%7d\t%s\n",
+ srv->index.value,
srv->readPipe->fd,
srv->pid,
srv->stats.uses,
link = link->next;
if (srv->flags.shutdown) {
- debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " has already SHUT DOWN.");
+ debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index << " has already SHUT DOWN.");
continue;
}
srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->flags.closing) {
- debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is CLOSING.");
+ debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index << " is CLOSING.");
continue;
}
if (srv->stats.pending) {
- debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is BUSY.");
+ debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index << " is BUSY.");
continue;
}
- debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " shutting down.");
+ debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index << " shutting down.");
/* the rest of the details is dealt with in the helperServerFree
* close handler
*/
link = link->next;
if (srv->flags.shutdown) {
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " has already SHUT DOWN.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " has already SHUT DOWN.");
continue;
}
srv->flags.shutdown = true; /* request it to shut itself down */
if (srv->flags.busy) {
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is BUSY.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " is BUSY.");
continue;
}
if (srv->flags.closing) {
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is CLOSING.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " is CLOSING.");
continue;
}
if (srv->flags.reserved) {
if (shutting_down) {
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is RESERVED. Closing anyway.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " is RESERVED. Closing anyway.");
} else {
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is RESERVED. Not Shutting Down Yet.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " is RESERVED. Not Shutting Down Yet.");
continue;
}
}
- debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " shutting down.");
+ debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index << " shutting down.");
/* the rest of the details is dealt with in the helperStatefulServerFree
* close handler
if (!srv->flags.shutdown) {
assert(hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " exited");
+ debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index << " exited");
if (hlp->childs.needNew() > 0) {
debugs(80, DBG_IMPORTANT, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");
if (!srv->flags.shutdown) {
assert( hlp->childs.n_active > 0);
-- hlp->childs.n_active;
- debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " exited");
+ debugs(84, DBG_CRITICAL, "WARNING: " << hlp->id_name << " #" << srv->index << " exited");
if (hlp->childs.needNew() > 0) {
debugs(80, DBG_IMPORTANT, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");
helperRequestFree(r);
} else {
debugs(84, DBG_IMPORTANT, "helperHandleRead: unexpected reply on channel " <<
- request_number << " from " << hlp->id_name << " #" << srv->index + 1 <<
+ request_number << " from " << hlp->id_name << " #" << srv->index <<
" '" << srv->rbuf << "'");
}
assert(conn->fd == srv->readPipe->fd);
- debugs(84, 5, "helperHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index + 1);
+ debugs(84, 5, "helperHandleRead: " << len << " bytes from " << hlp->id_name << " #" << srv->index);
if (flag != COMM_OK || len == 0) {
srv->closePipesSafely();
if (!srv->stats.pending) {
/* someone spoke without being spoken to */
debugs(84, DBG_IMPORTANT, "helperHandleRead: unexpected read from " <<
- hlp->id_name << " #" << srv->index + 1 << ", " << (int)len <<
+ hlp->id_name << " #" << srv->index << ", " << (int)len <<
" bytes '" << srv->rbuf << "'");
srv->roffset = 0;
if (!spaceSize) {
debugs(84, DBG_IMPORTANT, "ERROR: Disconnecting from a " <<
"helper that overflowed " << srv->rbuf_sz << "-byte " <<
- "Squid input buffer: " << hlp->id_name << " #" <<
- (srv->index + 1));
+ "Squid input buffer: " << hlp->id_name << " #" << srv->index);
srv->closePipesSafely();
return;
}
assert(conn->fd == srv->readPipe->fd);
debugs(84, 5, "helperStatefulHandleRead: " << len << " bytes from " <<
- hlp->id_name << " #" << srv->index + 1);
+ hlp->id_name << " #" << srv->index);
if (flag != COMM_OK || len == 0) {
srv->closePipesSafely();
if (r == NULL) {
/* someone spoke without being spoken to */
debugs(84, DBG_IMPORTANT, "helperStatefulHandleRead: unexpected read from " <<
- hlp->id_name << " #" << srv->index + 1 << ", " << (int)len <<
+ hlp->id_name << " #" << srv->index << ", " << (int)len <<
" bytes '" << srv->rbuf << "'");
srv->roffset = 0;
if (!spaceSize) {
debugs(84, DBG_IMPORTANT, "ERROR: Disconnecting from a " <<
"helper that overflowed " << srv->rbuf_sz << "-byte " <<
- "Squid input buffer: " << hlp->id_name << " #" <<
- (srv->index + 1));
+ "Squid input buffer: " << hlp->id_name << " #" << srv->index);
srv->closePipesSafely();
return;
}
if (flag != COMM_OK) {
/* Helper server has crashed */
- debugs(84, DBG_CRITICAL, "helperDispatch: Helper " << srv->parent->id_name << " #" << srv->index + 1 << " has crashed");
+ debugs(84, DBG_CRITICAL, "helperDispatch: Helper " << srv->parent->id_name << " #" << srv->index << " has crashed");
return;
}
Comm::Write(srv->writePipe, srv->writebuf->content(), srv->writebuf->contentSize(), call, NULL);
}
- debugs(84, 5, "helperDispatch: Request sent to " << hlp->id_name << " #" << srv->index + 1 << ", " << strlen(r->buf) << " bytes");
+ debugs(84, 5, "helperDispatch: Request sent to " << hlp->id_name << " #" << srv->index << ", " << strlen(r->buf) << " bytes");
++ srv->stats.uses;
++ srv->stats.pending;
return;
}
- debugs(84, 9, "helperStatefulDispatch busying helper " << hlp->id_name << " #" << srv->index + 1);
+ debugs(84, 9, "helperStatefulDispatch busying helper " << hlp->id_name << " #" << srv->index);
if (r->placeholder == 1) {
/* a callback is needed before this request can _use_ a helper. */
CommIoCbPtrFun(helperStatefulDispatchWriteDone, hlp));
Comm::Write(srv->writePipe, r->buf, strlen(r->buf), call, NULL);
debugs(84, 5, "helperStatefulDispatch: Request sent to " <<
- hlp->id_name << " #" << srv->index + 1 << ", " <<
+ hlp->id_name << " #" << srv->index << ", " <<
(int) strlen(r->buf) << " bytes");
++ srv->stats.uses;