/*
- * $Id: client_side.cc,v 1.250 1998/04/02 05:35:21 rousskov Exp $
+ * $Id: client_side.cc,v 1.251 1998/04/02 06:35:51 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
comm_write(fd, buf, writelen, clientWriteComplete, http, freefunc);
}
+static
+void
+clientKeepaliveNextRequest(clientHttpRequest * http)
+{
+ ConnStateData *conn = http->conn;
+ StoreEntry *entry;
+ conn->defer.until = 0; /* Kick it to read a new request */
+ httpRequestFree(http);
+ if ((http = conn->chr) != NULL) {
+ debug(33, 1) ("clientKeepaliveNextRequest: FD %d Sending next\n",
+ conn->fd);
+ entry = http->entry;
+ if (0 == storeClientCopyPending(entry, http)) {
+ if (entry->store_status == STORE_ABORTED)
+ debug(33, 0) ("clientWriteComplete: entry->swap_status == STORE_ABORTED\n");
+ storeClientCopy(entry,
+ http->out.offset,
+ http->out.offset,
+ SM_PAGE_SIZE,
+ memAllocate(MEM_4K_BUF),
+ clientSendMoreData,
+ http);
+ }
+ } else {
+ debug(33, 5) ("clientWriteComplete: FD %d reading next request\n",
+ conn->fd);
+ fd_note(conn->fd, "Reading next request");
+ /*
+ * Set the timeout BEFORE calling clientReadRequest().
+ */
+ commSetTimeout(conn->fd, 15, requestTimeout, conn);
+ clientReadRequest(conn->fd, conn); /* Read next request */
+ /*
+ * Note, the FD may be closed at this point.
+ */
+ }
+}
+
static void
clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *data)
{
clientHttpRequest *http = data;
- ConnStateData *conn;
StoreEntry *entry = http->entry;
int done;
http->out.size += size;
comm_close(fd);
} else if (EBIT_TEST(http->request->flags, REQ_PROXY_KEEPALIVE)) {
debug(33, 5) ("clientWriteComplete: FD %d Keeping Alive\n", fd);
- conn = http->conn;
- conn->defer.until = 0; /* Kick it to read a new request */
- httpRequestFree(http);
- if ((http = conn->chr) != NULL) {
- debug(33, 1) ("clientWriteComplete: FD %d Sending next request\n", fd);
- if (!storeClientCopyPending(http->entry, http)) {
- if (entry->store_status == STORE_ABORTED)
- debug(33, 0) ("clientWriteComplete: entry->swap_status == STORE_ABORTED\n");
- storeClientCopy(http->entry,
- http->out.offset,
- http->out.offset,
- SM_PAGE_SIZE,
- memAllocate(MEM_4K_BUF),
- clientSendMoreData,
- http);
- }
- } else {
- debug(33, 5) ("clientWriteComplete: FD %d reading next request\n", fd);
- fd_note(fd, "Reading next request");
- /*
- * Set the timeout BEFORE calling clientReadRequest().
- */
- commSetTimeout(fd, 15, requestTimeout, conn);
- clientReadRequest(fd, conn); /* Read next request */
- /*
- * Note, the FD may be closed at this point.
- */
- }
+ clientKeepaliveNextRequest(http);
} else {
comm_close(fd);
}
http->entry = NULL;
http->out.size += size;
http->al.http.code = 304;
- if (flag != COMM_ERR_CLOSING)
+ if (flag == COMM_ERR_CLOSING) {
+ (void) 0;
+ } else if (flag != COMM_OK) {
+ comm_close(fd);
+ } else if (EBIT_TEST(http->request->flags, REQ_PROXY_KEEPALIVE)) {
+ debug(33, 5) ("clientHandleIMSComplete: FD %d Keeping Alive\n", fd);
+ clientKeepaliveNextRequest(http);
+ } else {
comm_close(fd);
+ }
}
/*
/* ok, it is a miss or a "dirty" hit (will contact other servers) */
/* are we allowed to contact other servers? */
if (EBIT_TEST(r->flags, REQ_CC_ONLY_IF_CACHED)) {
- /* future interface: if (r->cache_control && EBIT_TEST(r->cache_control->mask, CC_ONLY_IF_CACHED)) { */
+ /* future interface: if (r->cache_control && EBIT_TEST(r->cache_control->mask, CC_ONLY_IF_CACHED)) { */
/* nope, bailing out */
clientProcessOnlyIfCachedMiss(http);
return;
req_hdr = t;
header_sz = headersEnd(req_hdr, conn->in.offset - (req_hdr - inbuf));
if (0 == header_sz) {
- debug(33,3)("parseHttpRequest: header_sz == 0\n");
+ debug(33, 3) ("parseHttpRequest: header_sz == 0\n");
xfree(inbuf);
*status = 0;
return NULL;