c->valid = 0;
if (c->locks) {
debug(45, 3) ("cbdataFree: %p has %d locks, not freeing\n",
- p, c->locks);
+ p, c->locks);
return;
}
hash_remove_link(htable, (hash_link *) c);
+
/*
- * $Id: client.cc,v 1.24 1997/08/10 04:42:34 wessels Exp $
+ * $Id: client.cc,v 1.25 1997/08/10 06:34:27 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
/*
- * $Id: comm.cc,v 1.184 1997/08/10 04:42:36 wessels Exp $
+ * $Id: comm.cc,v 1.185 1997/08/10 06:34:27 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
cs->port = port;
cs->callback = callback;
cs->data = data;
- cbdataLock(data);
+ cbdataLock(cs->data);
comm_add_close_handler(fd, commConnectFree, cs);
cs->locks++;
ipcache_nbgethostbyname(host, commConnectDnsHandle, cs);
commConnectFree(fd, cs);
if (cbdataValid(data))
callback(fd, status, data);
- cbdataUnlock(data);
+ cbdataUnlock(cs->data);
}
static void
assert(fd >= 0);
assert(fd < Squid_MaxFD);
F = &fd_table[fd];
- if (!F->open) {
- debug(5, 1) ("comm_close: FD %d is not open!\n", fd);
- return;
- }
+ assert(F->open);
assert(F->type != FD_FILE);
CommWriteStateCallbackAndFree(fd, COMM_ERROR);
commCallCloseHandlers(fd);
+ if (F->uses) /* assume persistent connect count */
+ pconnHistCount(1, F->uses);
fd_close(fd); /* update fdstat */
#if USE_ASYNC_IO
aioClose(fd);
/*
- * $Id: dns.cc,v 1.39 1997/07/26 04:48:28 wessels Exp $
+ * $Id: dns.cc,v 1.40 1997/08/10 06:34:28 wessels Exp $
*
* DEBUG: section 34 Dnsserver interface
* AUTHOR: Harvest Derived
0,
COMM_NOCLOEXEC,
"dnsserver listen socket");
- if (cfd == COMM_ERROR) {
+ if (cfd < 0) {
debug(34, 0) ("dnsOpenServer: Failed to create dnsserver\n");
return -1;
}
/*
- * $Id: errorpage.cc,v 1.62 1997/08/10 04:42:37 wessels Exp $
+ * $Id: errorpage.cc,v 1.63 1997/08/10 06:34:29 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
}
void
-errorAppendEntry(const StoreEntry * entry, ErrorState * err)
+errorAppendEntry(StoreEntry * entry, ErrorState * err)
{
char *buf;
int len;
/*
- * $Id: http.cc,v 1.181 1997/08/10 04:42:38 wessels Exp $
+ * $Id: http.cc,v 1.182 1997/08/10 06:34:29 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
static char *httpStatusString _PARAMS((int status));
static STABH httpAbort;
static HttpStateData *httpBuildState _PARAMS((int, StoreEntry *, request_t *, peer *));
-static int httpSocketOpen _PARAMS((StoreEntry *, const request_t *));
+static int httpSocketOpen _PARAMS((StoreEntry *, request_t *));
+static void httpRestart _PARAMS((HttpStateData *));
static void
-httpStateFree(int fdunused, void *data)
+httpStateFree(int fd, void *data)
{
HttpStateData *httpState = data;
if (httpState == NULL)
debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n",
fd, xstrerror());
} else if (len == 0 && entry->mem_obj->e_current_len == 0) {
- httpState->eof = 1;
- err = xcalloc(1, sizeof(ErrorState));
- err->type = ERR_ZERO_SIZE_OBJECT;
- err->errno = errno;
- err->http_status = HTTP_SERVICE_UNAVAILABLE;
- err->request = requestLink(httpState->request);
- errorAppendEntry(entry, err);
- storeAbort(entry, 0);
- comm_close(fd);
+ if (fd_table[fd].uses > 1) {
+ httpRestart(httpState);
+ } else {
+ httpState->eof = 1;
+ err = xcalloc(1, sizeof(ErrorState));
+ err->type = ERR_ZERO_SIZE_OBJECT;
+ err->errno = errno;
+ err->http_status = HTTP_SERVICE_UNAVAILABLE;
+ err->request = requestLink(httpState->request);
+ errorAppendEntry(entry, err);
+ storeAbort(entry, 0);
+ comm_close(fd);
+ }
} else if (len == 0) {
/* Connection closed; retrieval done. */
httpState->eof = 1;
}
static int
-httpSocketOpen(StoreEntry * entry, const request_t * request)
+httpSocketOpen(StoreEntry * entry, request_t * request)
{
int fd;
ErrorState *err;
if ((fd = pconnPop(e->host, e->http_port)) >= 0) {
debug(0, 0) ("httpStart: reusing pconn FD %d\n", fd);
httpState = httpBuildState(fd, entry, request, e);
+ commSetTimeout(httpState->fd,
+ Config.Timeout.connect,
+ httpTimeout,
+ httpState);
httpConnectDone(fd, COMM_OK, httpState);
return;
}
if ((fd = pconnPop(request->host, request->port)) >= 0) {
debug(0, 0) ("httpStart: reusing pconn FD %d\n", fd);
httpState = httpBuildState(fd, entry, request, e);
+ commSetTimeout(httpState->fd,
+ Config.Timeout.connect,
+ httpTimeout,
+ httpState);
httpConnectDone(fd, COMM_OK, httpState);
return;
}
httpState);
}
+static void
+httpRestart(HttpStateData * httpState)
+{
+ /* restart a botched request from a persistent connection */
+ debug(0, 0) ("Retrying HTTP request for %s\n", httpState->entry->url);
+ if (httpState->fd >= 0) {
+ comm_remove_close_handler(httpState->fd, httpStateFree, httpState);
+ comm_close(httpState->fd);
+ httpState->fd = -1;
+ }
+ httpState->fd = httpSocketOpen(httpState->entry, httpState->request);
+ if (httpState->fd < 0)
+ return;
+ comm_add_close_handler(httpState->fd, httpStateFree, httpState);
+ commSetTimeout(httpState->fd,
+ Config.Timeout.connect,
+ httpTimeout,
+ httpState);
+ commConnectStart(httpState->fd,
+ httpState->request->host,
+ httpState->request->port,
+ httpConnectDone,
+ httpState);
+}
+
static void
httpConnectDone(int fd, int status, void *data)
{
comm_close(fd);
} else {
fd_note(fd, entry->url);
+ fd_table[fd].uses++;
commSetSelect(fd, COMM_SELECT_WRITE, httpSendRequest, httpState, 0);
}
}
assert(p->nfds > 0);
fd = p->fds[0];
pconnRemoveFD(p, fd);
+ commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
+ commSetTimeout(fd, -1, NULL, NULL);
}
xfree(key);
return fd;
extern void urlInitialize _PARAMS((void));
extern request_t *urlParse _PARAMS((method_t, char *));
extern char *urlCanonical _PARAMS((const request_t *, char *));
-extern request_t *requestLink _PARAMS((const request_t *));
+extern request_t *requestLink _PARAMS((request_t *));
extern void requestUnlink _PARAMS((request_t *));
extern int matchDomainName _PARAMS((const char *d, const char *h));
extern int urlCheckRequest _PARAMS((const request_t *));
extern peer_t parseNeighborType _PARAMS((const char *s));
extern void errorSend _PARAMS((int fd, ErrorState *));
-extern void errorAppendEntry _PARAMS((const StoreEntry *, ErrorState *));
+extern void errorAppendEntry _PARAMS((StoreEntry *, ErrorState *));
extern void errorInitialize _PARAMS((void));
extern OBJH stat_io_get;
/*
- * $Id: stat.cc,v 1.153 1997/08/10 04:42:47 wessels Exp $
+ * $Id: stat.cc,v 1.154 1997/08/10 06:34:32 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
#define PCONN_HIST_SZ 256
int client_pconn_hist[PCONN_HIST_SZ];
+int server_pconn_hist[PCONN_HIST_SZ];
/* process utilization information */
static void
obj->proto_stat_data[i].kb.now = 0;
}
*object = obj;
- for (i = 0; i < PCONN_HIST_SZ; i++)
+ for (i = 0; i < PCONN_HIST_SZ; i++) {
client_pconn_hist[i] = 0;
+ server_pconn_hist[i] = 0;
+ }
}
void
/* what == 0 for client, 1 for server */
if (what == 0)
client_pconn_hist[i]++;
+ else if (what == 1)
+ server_pconn_hist[i]++;
+ else
+ fatal_dump("pconnHistCount: bad 'what' arg");
}
void
storeAppendPrintf(e,
"Client-side persistent connection counts:\n"
"\n"
- "req/\n"
- "conn count\n"
- "---- ---------\n");
+ "\treq/\n"
+ "\tconn count\n"
+ "\t---- ---------\n");
for (i = 0; i < PCONN_HIST_SZ; i++) {
if (client_pconn_hist[i] == 0)
continue;
- storeAppendPrintf(e, "%4d %9d\n", i, client_pconn_hist[i]);
+ storeAppendPrintf(e, "\t%4d %9d\n", i, client_pconn_hist[i]);
+ }
+ storeAppendPrintf(e,
+ "\n"
+ "Server-side persistent connection counts:\n"
+ "\n"
+ "\treq/\n"
+ "\tconn count\n"
+ "\t---- ---------\n");
+ for (i = 0; i < PCONN_HIST_SZ; i++) {
+ if (server_pconn_hist[i] == 0)
+ continue;
+ storeAppendPrintf(e, "\t%4d %9d\n", i, server_pconn_hist[i]);
}
}
int flags;
int bytes_read;
int bytes_written;
+ int uses; /* ie # req's over persistent conn */
struct _fde_disk {
DWCB *wrt_handle;
void *wrt_handle_data;
/*
- * $Id: url.cc,v 1.61 1997/08/10 04:42:50 wessels Exp $
+ * $Id: url.cc,v 1.62 1997/08/10 06:34:33 wessels Exp $
*
* DEBUG: section 23 URL Parsing
* AUTHOR: Duane Wessels
request_t *
-requestLink(const request_t * request)
+requestLink(request_t * request)
{
request->link_count++;
return request;