Index: squid/src/helper.c diff -c squid/src/helper.c:1.34.2.16 squid/src/helper.c:1.34.2.17 *** squid/src/helper.c:1.34.2.16 Thu Mar 11 08:26:30 2004 --- squid/src/helper.c Sat Nov 6 08:24:51 2004 *************** *** 100,108 **** continue; } hlp->n_running++; srv = cbdataAlloc(helper_server); srv->pid = x; - srv->flags.alive = 1; srv->index = k; srv->rfd = rfd; srv->wfd = wfd; --- 100,108 ---- continue; } hlp->n_running++; + hlp->n_active++; srv = cbdataAlloc(helper_server); srv->pid = x; srv->index = k; srv->rfd = rfd; srv->wfd = wfd; *************** *** 125,130 **** --- 125,131 ---- if (wfd != rfd) commSetNonBlocking(wfd); comm_add_close_handler(rfd, helperServerFree, srv); + commSetSelect(srv->rfd, COMM_SELECT_READ, helperHandleRead, srv, 0); } hlp->last_restart = squid_curtime; safe_free(shortname); *************** *** 178,186 **** continue; } hlp->n_running++; srv = cbdataAlloc(helper_stateful_server); srv->pid = x; - srv->flags.alive = 1; srv->flags.reserved = 0; srv->stats.submits = 0; srv->index = k; --- 179,187 ---- continue; } hlp->n_running++; + hlp->n_active++; srv = cbdataAlloc(helper_stateful_server); srv->pid = x; srv->flags.reserved = 0; srv->stats.submits = 0; srv->index = k; *************** *** 207,212 **** --- 208,214 ---- if (wfd != rfd) commSetNonBlocking(wfd); comm_add_close_handler(rfd, helperStatefulServerFree, srv); + commSetSelect(srv->rfd, COMM_SELECT_READ, helperStatefulHandleRead, srv, 0); } hlp->last_restart = squid_curtime; safe_free(shortname); *************** *** 363,374 **** srv = link->data; tt = 0.001 * tvSubMsec(srv->dispatch_time, srv->flags.busy ? current_time : srv->answer_time); ! storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c%c\t%7.3f\t%7d\t%s\n", srv->index + 1, srv->rfd, srv->pid, srv->stats.uses, - srv->flags.alive ? 'A' : ' ', srv->flags.busy ? 'B' : ' ', srv->flags.closing ? 'C' : ' ', srv->flags.shutdown ? 'S' : ' ', --- 365,375 ---- srv = link->data; tt = 0.001 * tvSubMsec(srv->dispatch_time, srv->flags.busy ? current_time : srv->answer_time); ! storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c\t%7.3f\t%7d\t%s\n", srv->index + 1, srv->rfd, srv->pid, srv->stats.uses, srv->flags.busy ? 'B' : ' ', srv->flags.closing ? 'C' : ' ', srv->flags.shutdown ? 'S' : ' ', *************** *** 412,423 **** for (link = hlp->servers.head; link; link = link->next) { srv = link->data; tt = 0.001 * tvSubMsec(srv->dispatch_time, current_time); ! storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c%c%c\t%7.3f\t%7d\t%s\n", srv->index + 1, srv->rfd, srv->pid, srv->stats.uses, - srv->flags.alive ? 'A' : ' ', srv->flags.busy ? 'B' : ' ', srv->flags.closing ? 'C' : ' ', srv->flags.reserved ? 'R' : ' ', --- 413,423 ---- for (link = hlp->servers.head; link; link = link->next) { srv = link->data; tt = 0.001 * tvSubMsec(srv->dispatch_time, current_time); ! storeAppendPrintf(sentry, "%7d\t%7d\t%7d\t%11d\t%c%c%c%c\t%7.3f\t%7d\t%s\n", srv->index + 1, srv->rfd, srv->pid, srv->stats.uses, srv->flags.busy ? 'B' : ' ', srv->flags.closing ? 'C' : ' ', srv->flags.reserved ? 'R' : ' ', *************** *** 444,462 **** helper_server *srv; srv = link->data; link = link->next; ! if (!srv->flags.alive) { ! debug(84, 3) ("helperShutdown: %s #%d is NOT ALIVE.\n", hlp->id_name, srv->index + 1); continue; } srv->flags.shutdown = 1; /* request it to shut itself down */ ! if (srv->flags.busy) { ! debug(84, 3) ("helperShutdown: %s #%d is BUSY.\n", hlp->id_name, srv->index + 1); continue; } ! if (srv->flags.closing) { ! debug(84, 3) ("helperShutdown: %s #%d is CLOSING.\n", hlp->id_name, srv->index + 1); continue; } --- 444,464 ---- helper_server *srv; srv = link->data; link = link->next; ! if (srv->flags.shutdown) { ! debug(84, 3) ("helperShutdown: %s #%d is already shut down\n", hlp->id_name, srv->index + 1); continue; } + hlp->n_active--; + assert(hlp->n_active>= 0); srv->flags.shutdown = 1; /* request it to shut itself down */ ! if (srv->flags.closing) { ! debug(84, 3) ("helperShutdown: %s #%d is CLOSING.\n", hlp->id_name, srv->index + 1); continue; } ! if (srv->flags.busy) { ! debug(84, 3) ("helperShutdown: %s #%d is BUSY.\n", hlp->id_name, srv->index + 1); continue; } *************** *** 476,486 **** while (link) { srv = link->data; link = link->next; ! if (!srv->flags.alive) { ! debug(84, 3) ("helperStatefulShutdown: %s #%d is NOT ALIVE.\n", hlp->id_name, srv->index + 1); continue; } srv->flags.shutdown = 1; /* request it to shut itself down */ if (srv->flags.busy) { debug(84, 3) ("helperStatefulShutdown: %s #%d is BUSY.\n", --- 478,490 ---- while (link) { srv = link->data; link = link->next; ! if (srv->flags.shutdown) { ! debug(84, 3) ("helperStatefulShutdown: %s #%d is already shut down.\n", hlp->id_name, srv->index + 1); continue; } + hlp->n_active--; + assert(hlp->n_active>= 0); srv->flags.shutdown = 1; /* request it to shut itself down */ if (srv->flags.busy) { debug(84, 3) ("helperStatefulShutdown: %s #%d is BUSY.\n", *************** *** 576,585 **** hlp->n_running--; assert(hlp->n_running>= 0); if (!srv->flags.shutdown) { debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", hlp->id_name, srv->index + 1, fd); ! if (hlp->n_running <= hlp->n_to_start / 2) { ! debug(80, 0) ("Too few %s processes are running", hlp->id_name); if (hlp->last_restart> squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); debug(80, 0) ("Starting new helpers\n"); --- 580,591 ---- hlp->n_running--; assert(hlp->n_running>= 0); if (!srv->flags.shutdown) { + hlp->n_active--; + assert(hlp->n_active>= 0); debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", hlp->id_name, srv->index + 1, fd); ! if (hlp->n_active <= hlp->n_to_start / 2) { ! debug(80, 0) ("Too few %s processes are running\n", hlp->id_name); if (hlp->last_restart> squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); debug(80, 0) ("Starting new helpers\n"); *************** *** 614,623 **** hlp->n_running--; assert(hlp->n_running>= 0); if (!srv->flags.shutdown) { debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", hlp->id_name, srv->index + 1, fd); ! if (hlp->n_running <= hlp->n_to_start / 2) { ! debug(80, 0) ("Too few %s processes are running", hlp->id_name); if (hlp->last_restart> squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); debug(80, 0) ("Starting new helpers\n"); --- 620,631 ---- hlp->n_running--; assert(hlp->n_running>= 0); if (!srv->flags.shutdown) { + hlp->n_active--; + assert(hlp->n_active>= 0); debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", hlp->id_name, srv->index + 1, fd); ! if (hlp->n_active <= hlp->n_to_start / 2) { ! debug(80, 0) ("Too few %s processes are running\n", hlp->id_name); if (hlp->last_restart> squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); debug(80, 0) ("Starting new helpers\n"); *************** *** 652,657 **** --- 660,666 ---- comm_close(fd); return; } + commSetSelect(srv->rfd, COMM_SELECT_READ, helperHandleRead, srv, 0); srv->offset += len; srv->buf[srv->offset] = '0円'; r = srv->request; *************** *** 676,685 **** if (cbdataValid(r->data)) r->callback(r->data, srv->buf); helperRequestFree(r); ! if (!srv->flags.shutdown) helperKickQueue(hlp); ! } else { ! commSetSelect(srv->rfd, COMM_SELECT_READ, helperHandleRead, srv, 0); } } --- 685,698 ---- if (cbdataValid(r->data)) r->callback(r->data, srv->buf); helperRequestFree(r); ! if (!srv->flags.shutdown) { helperKickQueue(hlp); ! } else if (!srv->flags.closing) { ! int wfd = srv->wfd; ! srv->flags.closing = 1; ! srv->wfd = -1; ! comm_close(wfd); ! } } } *************** *** 704,709 **** --- 717,723 ---- comm_close(fd); return; } + commSetSelect(srv->rfd, COMM_SELECT_READ, helperStatefulHandleRead, srv, 0); srv->offset += len; srv->buf[srv->offset] = '0円'; r = srv->request; *************** *** 730,737 **** debug(84, 1) ("StatefulHandleRead: no callback data registered\n"); } helperStatefulRequestFree(r); - } else { - commSetSelect(srv->rfd, COMM_SELECT_READ, helperStatefulHandleRead, srv, 0); } } --- 744,749 ---- *************** *** 822,828 **** srv = n->data; if (srv->flags.busy) continue; ! if (!srv->flags.alive) continue; return srv; } --- 834,840 ---- srv = n->data; if (srv->flags.busy) continue; ! if (srv->flags.shutdown) continue; return srv; } *************** *** 843,849 **** continue; if (srv->flags.reserved) continue; ! if (!srv->flags.alive) continue; if ((hlp->IsAvailable != NULL) && (srv->data != NULL) && !(hlp->IsAvailable(srv->data))) continue; --- 855,861 ---- continue; if (srv->flags.reserved) continue; ! if (srv->flags.shutdown) continue; if ((hlp->IsAvailable != NULL) && (srv->data != NULL) && !(hlp->IsAvailable(srv->data))) continue; *************** *** 873,882 **** NULL, /* Handler */ NULL, /* Handler-data */ NULL); /* free */ - commSetSelect(srv->rfd, - COMM_SELECT_READ, - helperHandleRead, - srv, 0); debug(84, 5) ("helperDispatch: Request sent to %s #%d, %d bytes\n", hlp->id_name, srv->index + 1, (int) strlen(r->buf)); srv->stats.uses++; --- 885,890 ---- *************** *** 911,920 **** NULL, /* Handler */ NULL, /* Handler-data */ NULL); /* free */ - commSetSelect(srv->rfd, - COMM_SELECT_READ, - helperStatefulHandleRead, - srv, 0); debug(84, 5) ("helperStatefulDispatch: Request sent to %s #%d, %d bytes\n", hlp->id_name, srv->index + 1, (int) strlen(r->buf)); srv->stats.uses++; --- 919,924 ---- Index: squid/src/structs.h diff -c squid/src/structs.h:1.408.2.30 squid/src/structs.h:1.408.2.31 *** squid/src/structs.h:1.408.2.30 Tue Oct 5 16:56:36 2004 --- squid/src/structs.h Sat Nov 6 08:24:51 2004 *************** *** 2027,2032 **** --- 2027,2033 ---- const char *id_name; int n_to_start; int n_running; + int n_active; int ipc_type; time_t last_queue_warn; struct { *************** *** 2046,2051 **** --- 2047,2053 ---- const char *id_name; int n_to_start; int n_running; + int n_active; int ipc_type; MemPool *datapool; HLPSAVAIL *IsAvailable; *************** *** 2075,2081 **** helper *parent; helper_request *request; struct _helper_flags { - unsigned int alive:1; unsigned int busy:1; unsigned int closing:1; unsigned int shutdown:1; --- 2077,2082 ----

AltStyle によって変換されたページ (->オリジナル) /