/*
- * $Id: cache_cf.cc,v 1.357 2000/12/04 20:40:36 wessels Exp $
+ * $Id: cache_cf.cc,v 1.358 2000/12/05 06:24:00 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
#endif
} else if (!strcasecmp(token, "allow-miss")) {
p->options.allow_miss = 1;
+ } else if (!strcasecmp(token, "max-conn=")) {
+ p->max_conn = atoi(token + 9);
} else {
debug(3, 0) ("parse_peer: token='%s'\n", token);
self_destruct();
/*
- * $Id: forward.cc,v 1.75 2000/11/01 04:03:14 wessels Exp $
+ * $Id: forward.cc,v 1.76 2000/12/05 06:24:00 wessels Exp $
*
* DEBUG: section 17 Request Forwarding
* AUTHOR: Duane Wessels
static void fwdLogReplyStatus(int tries, http_status status);
static OBJH fwdStats;
static STABH fwdAbort;
+static peer *fwdStateServerPeer(FwdState *);
#define MAX_FWD_STATS_IDX 9
static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][HTTP_INVALID_HEADER + 1];
static Logfile *logfile = NULL;
#endif
+static peer *
+fwdStateServerPeer(FwdState * fwdState)
+{
+ if (NULL == fwdState)
+ return NULL;
+ if (NULL == fwdState->servers)
+ return NULL;
+ return fwdState->servers->peer;
+}
+
static void
fwdServerFree(FwdServer * fs)
{
{
StoreEntry *e = fwdState->entry;
int sfd;
+ peer *p;
debug(17, 3) ("fwdStateFree: %p\n", fwdState);
assert(e->mem_obj);
#if URL_CHECKSUM_DEBUG
}
if (storePendingNClients(e) > 0)
assert(!EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT));
+ p = fwdStateServerPeer(fwdState);
fwdServersFree(&fwdState->servers);
requestUnlink(fwdState->request);
fwdState->request = NULL;
fwdState->server_fd = -1;
debug(17, 3) ("fwdStateFree: closing FD %d\n", sfd);
comm_close(sfd);
+ if (p)
+ p->stats.conn_open--;
}
cbdataFree(fwdState);
}
err->dnsserver_msg = xstrdup(dns_error_message);
err->request = requestLink(request);
fwdFail(fwdState, err);
+ if (fs->peer)
+ fs->peer->stats.conn_open--;
comm_close(server_fd);
} else if (status != COMM_OK) {
assert(fs);
}
err->request = requestLink(request);
fwdFail(fwdState, err);
- if (fs->peer)
+ if (fs->peer) {
peerConnectFailed(fs->peer);
+ fs->peer->stats.conn_open--;
+ }
comm_close(server_fd);
} else {
debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, storeUrl(fwdState->entry));
FwdState *fwdState = data;
StoreEntry *entry = fwdState->entry;
ErrorState *err;
+ peer *p = fwdStateServerPeer(fwdState);
debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, storeUrl(entry));
assert(fd == fwdState->server_fd);
if (entry->mem_obj->inmem_hi == 0) {
if (fwdState->servers->peer)
peerConnectFailed(fwdState->servers->peer);
}
+ if (p)
+ p->stats.conn_open--;
comm_close(fd);
}
}
fwdState->server_fd = fd;
fwdState->n_tries++;
+ /*
+ * stats.conn_open is used to account for the number of
+ * connections that we have open to the peer, so we can limit
+ * based on the max-conn option. We need to increment here,
+ * even if the connection may fail.
+ */
+ if (fs->peer)
+ fs->peer->stats.conn_open++;
comm_add_close_handler(fd, fwdServerClosed, fwdState);
commSetTimeout(fd,
ctimeout,
static void
fwdDispatch(FwdState * fwdState)
{
- peer *p;
+ peer *p = NULL;
request_t *request = fwdState->request;
StoreEntry *entry = fwdState->entry;
ErrorState *err;
* transient (network) error; its a bug.
*/
fwdState->flags.dont_retry = 1;
+ /*
+ * this assertion exists because if we are connected to
+ * a peer, then we need to decrement p->stats.conn_open.
+ */
+ assert(NULL == p);
comm_close(fwdState->server_fd);
break;
}
/*
- * $Id: neighbors.cc,v 1.288 2000/11/07 22:04:38 wessels Exp $
+ * $Id: neighbors.cc,v 1.289 2000/12/05 06:24:00 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
return 0;
if (!neighborUp(p))
return 0;
+ if (p->max_conn)
+ if (p->stats.conn_open >= p->max_conn)
+ return 0;
return 1;
}
storeAppendPrintf(sentry, "Status : %s\n",
neighborUp(e) ? "Up" : "Down");
storeAppendPrintf(sentry, "AVG RTT : %d msec\n", e->stats.rtt);
+ storeAppendPrintf(sentry, "OPEN CONNS : %d\n", e->stats.conn_open);
storeAppendPrintf(sentry, "LAST QUERY : %8d seconds ago\n",
(int) (squid_curtime - e->stats.last_query));
storeAppendPrintf(sentry, "LAST REPLY : %8d seconds ago\n",