/*
- * $Id: StatHist.cc,v 1.8 1998/04/27 17:25:03 rousskov Exp $
+ * $Id: StatHist.cc,v 1.9 1998/05/27 20:31:31 wessels Exp $
*
* DEBUG: section 62 Generic Histogram
* AUTHOR: Duane Wessels
static void statHistInit(StatHist * H, int capacity, hbase_f val_in, hbase_f val_out, double min, double max);
static int statHistBin(const StatHist * H, double v);
static double statHistVal(const StatHist * H, int bin);
-static void statHistBinDumper(StoreEntry * sentry, int idx, double val, double size, int count);
-
-
+static StatHistBinDumper statHistBinDumper;
/* low level init, higher level functions has less params */
static void
}
void
-statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper bd)
+statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper *bd)
{
int i;
double left_border = H->min;
{
return x;
}
+
void
statHistEnumInit(StatHist * H, int last_enum)
{
}
void
-statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count)
+statHistEnumDumper(StoreEntry * sentry, int idx, double val, double size, int count)
{
if (count)
storeAppendPrintf(sentry, "%2d\t %5d\t %5d\n",
idx, (int) val, count);
}
+
+void
+statHistIntInit(StatHist * H, int n)
+{
+ statHistInit(H, n, &Null, &Null, 0, n-1);
+}
+
+void
+statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count)
+{
+ if (count)
+ storeAppendPrintf(sentry, "%9d\t%9d\n", (int) val, count);
+}
queried only when Squid starts up, not for every request.
DOC_END
+NAME: incoming_min_rate
+TYPE: int
+LOC: Config.incoming_rate.min
+DEFAULT: 16
+DOC_NONE
+
+NAME: incoming_max_rate
+TYPE: int
+LOC: Config.incoming_rate.max
+DEFAULT: 2
+DOC_NONE
+
EOF
/*
- * $Id: client_side.cc,v 1.315 1998/05/27 18:35:22 wessels Exp $
+ * $Id: client_side.cc,v 1.316 1998/05/27 20:31:33 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
static int clientCachable(clientHttpRequest * http);
static int clientHierarchical(clientHttpRequest * http);
static int clientCheckContentLength(request_t * r);
+static int httpAcceptDefer(void);
static int
checkAccelOnly(clientHttpRequest * http)
}
}
-int
-httpAcceptDefer(int fdnotused, void *notused)
+static int
+httpAcceptDefer(void)
{
static time_t last_warn = 0;
if (fdNFree() >= RESERVED_FD)
/* Handle a new connection on HTTP socket. */
void
-httpAccept(int sock, void *notused)
+httpAccept(int sock, void *data)
{
+ int *N = data;
int fd = -1;
ConnStateData *connState = NULL;
struct sockaddr_in peer;
struct sockaddr_in me;
int max = 10;
- while (max-- && !httpAcceptDefer(sock, notused)) {
+ while (max-- && !httpAcceptDefer()) {
memset(&peer, '\0', sizeof(struct sockaddr_in));
memset(&me, '\0', sizeof(struct sockaddr_in));
commSetSelect(sock, COMM_SELECT_READ, httpAccept, NULL, 0);
commSetTimeout(fd, Config.Timeout.request, requestTimeout, connState);
commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, connState, 0);
commSetDefer(fd, clientReadDefer, connState);
+ (*N)++;
}
}
continue;
comm_listen(fd);
commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
- commSetDefer(fd, httpAcceptDefer, NULL);
+ /*commSetDefer(fd, httpAcceptDefer, NULL);*/
debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
(int) u->i, fd);
HttpSockets[NHttpSockets++] = fd;
/*
- * $Id: comm.cc,v 1.258 1998/05/20 22:07:10 wessels Exp $
+ * $Id: comm.cc,v 1.259 1998/05/27 20:31:34 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
#define MAX_POLL_TIME 1000
#endif
+#define commCheckIncoming \
+ ((++incoming_counter & \
+ (lastinc > 0 ? Config.incoming_rate.max : Config.incoming_rate.min)) == 0)
+
typedef struct {
char *host;
u_short port;
} ConnectStateData;
/* STATIC */
-static int polledinc = 0;
+static int incame = 0;
static int commBind(int s, struct in_addr, u_short port);
#if !HAVE_POLL
static int examine_select(fd_set *, fd_set *);
static void checkTimeouts(void);
static void commSetReuseAddr(int);
static void commSetNoLinger(int);
-#if HAVE_POLL
-static void comm_poll_incoming(void);
-#else
-static void comm_select_incoming(void);
-#endif
+static void comm_incoming(void);
static void CommWriteStateCallbackAndFree(int fd, int code);
#ifdef TCP_NODELAY
static void commSetTcpNoDelay(int);
return F->defer_check(fd, F->defer_data);
}
+#if OLD_CODE
#if HAVE_POLL
/* poll() version by:
}
/* TO FIX: repoll ICP connection here */
}
-
#else
static void
}
#endif
+#endif /* OLD_CODE */
+
+static void
+comm_incoming(void)
+{
+ int j;
+ incame = 0;
+ if (theInIcpConnection > 0)
+ icpHandleUdp(theInIcpConnection, &incame);
+ if (theInIcpConnection != theOutIcpConnection)
+ icpHandleUdp(theOutIcpConnection, &incame);
+ for (j = 0; j < NHttpSockets; j++) {
+ if (HttpSockets[j] < 0)
+ continue;
+ httpAccept(HttpSockets[j], &incame);
+ }
+ statHistCount(&Counter.comm_incoming, incame);
+}
+
static int
fdIsHttpOrIcp(int fd)
{
#if USE_ASYNC_IO
aioCheckCallbacks();
#endif
- comm_poll_incoming();
+ comm_incoming();
nfds = 0;
maxfd = Biggest_FD + 1;
for (i = 0; i < maxfd; i++) {
fd_table[fd].read_handler = NULL;
hdl(fd, fd_table[fd].read_data);
}
- if ((++incoming_counter & 15) == 0)
- comm_poll_incoming();
+ if (commCheckIncoming)
+ comm_incoming();
}
if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR)) {
debug(5, 5) ("comm_poll: FD %d ready for writing\n", fd);
fd_table[fd].write_handler = NULL;
hdl(fd, fd_table[fd].write_data);
}
- if ((++incoming_counter & 15) == 0)
- comm_poll_incoming();
+ if (commCheckIncoming)
+ comm_incoming();
}
if (revents & POLLNVAL) {
close_handler *ch;
if (F->open != 0)
fd_close(fd);
}
- lastinc = polledinc;
+ lastinc = incame;
}
return COMM_OK;
} while (timeout > current_dtime);
else
setSocketShutdownLifetimes(1);
}
- comm_select_incoming();
+ comm_incoming();
nfds = 0;
maxfd = Biggest_FD + 1;
for (i = 0; i < maxfd; i++) {
fd_table[fd].read_handler = NULL;
hdl(fd, fd_table[fd].read_data);
}
- if ((++incoming_counter & 15) == 0)
- comm_select_incoming();
+ if (commCheckIncoming)
+ comm_incoming();
}
if (FD_ISSET(fd, &writefds)) {
debug(5, 5) ("comm_select: FD %d ready for writing\n", fd);
fd_table[fd].write_handler = NULL;
hdl(fd, fd_table[fd].write_data);
}
- if ((++incoming_counter & 15) == 0)
- comm_select_incoming();
+ if (commCheckIncoming)
+ comm_incoming();
}
- lastinc = polledinc;
+ lastinc = incame;
}
return COMM_OK;
} while (timeout > current_dtime);
#endif
void
-icpHandleUdp(int sock, void *datanotused)
+icpHandleUdp(int sock, void *data)
{
+ int *N = data;
struct sockaddr_in from;
int from_len;
LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF);
sock, xstrerror());
break;
}
+ (*N)++;
icpCount(buf, RECV, (size_t) len, 0);
buf[len] = '\0';
debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n",
if (theInIcpConnection < 0)
fatal("Cannot open ICP Port");
commSetSelect(theInIcpConnection,
- COMM_SELECT_READ,
- icpHandleUdp,
- NULL, 0);
+ COMM_SELECT_READ,
+ icpHandleUdp,
+ NULL,
+ 0);
for (s = Config.mcast_group_list; s; s = s->next)
ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
debug(12, 1) ("Accepting ICP messages on port %d, FD %d.\n",
commSetSelect(theOutIcpConnection,
COMM_SELECT_READ,
icpHandleUdp,
- NULL, 0);
+ NULL,
+ 0);
debug(12, 1) ("Outgoing ICP messages on port %d, FD %d.\n",
(int) port, theOutIcpConnection);
fd_note(theOutIcpConnection, "Outgoing ICP socket");
extern int icpUdpSend(int, const struct sockaddr_in *, icp_common_t *, log_type, int);
extern PF icpHandleUdp;
extern PF httpAccept;
-extern DEFER httpAcceptDefer;
#ifdef SQUID_SNMP
extern PF snmpHandleUdp;
extern void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper bd);
extern void statHistLogInit(StatHist * H, int capacity, double min, double max);
extern void statHistEnumInit(StatHist * H, int last_enum);
-extern void statHistIntDumper(StoreEntry * sentry, int idx, double val, double size, int count);
+extern StatHistBinDumper statHistEnumDumper;
+extern StatHistBinDumper statHistIntDumper;
/* MemMeter */
/*
- * $Id: stat.cc,v 1.255 1998/05/26 17:37:48 wessels Exp $
+ * $Id: stat.cc,v 1.256 1998/05/27 20:31:37 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
static OBJH statAvg5min;
static OBJH statAvg60min;
static OBJH statUtilization;
+static OBJH statCountersHistograms;
#ifdef XMALLOC_STATISTICS
static void info_get_mallstat(int, int, StoreEntry *);
"Display cache metrics graphically",
statGraphDump, 0);
#endif
+ cachemgrRegister("histograms",
+ "Full Histogram Counts",
+ statCountersHistograms, 0);
}
static void
* Cache Digest Stuff
*/
statHistEnumInit(&C->cd.on_xition_count, CacheDigestHashFuncCount);
+ statHistEnumInit(&C->comm_incoming, 20);
}
/* add special cases here as they arrive */
statHistClean(&C->icp.reply_svc_time);
statHistClean(&C->dns.svc_time);
statHistClean(&C->cd.on_xition_count);
+ statHistClean(&C->comm_incoming);
}
/* add special cases here as they arrive */
statHistCopy(&dest->icp.reply_svc_time, &orig->icp.reply_svc_time);
statHistCopy(&dest->dns.svc_time, &orig->dns.svc_time);
statHistCopy(&dest->cd.on_xition_count, &orig->cd.on_xition_count);
+ statHistCopy(&dest->comm_incoming, &orig->comm_incoming);
}
static void
statCountersHistograms(StoreEntry * sentry)
{
+ StatCounters *f = &Counter;
#if TOO_MUCH_OUTPUT
storeAppendPrintf(sentry, "client_http.all_svc_time histogram:\n");
statHistDump(&f->client_http.all_svc_time, sentry, NULL);
storeAppendPrintf(sentry, "dns.svc_time histogram:\n");
statHistDump(&f->dns.svc_time, sentry, NULL);
#endif
+ storeAppendPrintf(sentry, "comm_incoming histogram:\n");
+ statHistDump(&f->comm_incoming, sentry, statHistIntDumper);
}
static void
struct {
size_t limit;
} MemPools;
+ struct {
+ int min;
+ int max;
+ } incoming_rate;
};
struct _SquidConfig2 {
int select_loops;
double cputime;
struct timeval timestamp;
+ StatHist comm_incoming;
};
struct _tlv {
typedef void STVLDCB(void *, int, int);
typedef double (*hbase_f) (double);
-typedef void (*StatHistBinDumper) (StoreEntry *, int idx, double val, double size, int count);
+typedef void StatHistBinDumper(StoreEntry *, int idx, double val, double size, int count);
/* append/vprintf's for Packer */
typedef void (*append_f) (void *, const char *buf, int size);