]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
client-proxy keep-alive connections almost working
authorwessels <>
Thu, 8 May 1997 13:22:01 +0000 (13:22 +0000)
committerwessels <>
Thu, 8 May 1997 13:22:01 +0000 (13:22 +0000)
src/client_side.cc
src/http.cc
src/ident.cc
src/redirect.cc
src/squid.h
src/ssl.cc
src/store.cc
src/tunnel.cc

index 3b45c009be27bf2b65db09288f9f2d2554a93566..f6ed1898189c6d48285e057c0bbc46a8ae23205a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.101 1997/05/05 03:43:38 wessels Exp $
+ * $Id: client_side.cc,v 1.102 1997/05/08 07:22:01 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
 #include "squid.h"
 
 static RH clientRedirectDone;
-static PIF icpHandleIMSReply;
+static STCB icpHandleIMSReply;
 static int clientGetsOldEntry _PARAMS((StoreEntry * new, StoreEntry * old, request_t * request));
-static int checkAccelOnly _PARAMS((icpStateData * icpState));
-
-static void
-clientLookupIdentDone(void *data)
-{
-    icpStateData *icpState = data;
-    clientAccessCheck(icpState, icpState->aclHandler);
-}
+static int checkAccelOnly _PARAMS((clientHttpRequest *));
 
 #if USE_PROXY_AUTH
 /* ProxyAuth code by Jon Thackray <jrmt@uk.gdscorp.com> */
 /* return 1 if allowed, 0 if denied */
 static int
-clientProxyAuthCheck(icpStateData * icpState)
+clientProxyAuthCheck(clientHttpRequest * http)
 {
     const char *proxy_user;
 
@@ -56,27 +49,27 @@ clientProxyAuthCheck(icpStateData * icpState)
      * an object of type cacheobj:// */
     if (Config.proxyAuth.File == NULL)
        return 1;
-    if (urlParseProtocol(icpState->url) == PROTO_CACHEOBJ)
+    if (urlParseProtocol(http->url) == PROTO_CACHEOBJ)
        return 1;
 
     if (Config.proxyAuth.IgnoreDomains) {
-       if (aclMatchRegex(Config.proxyAuth.IgnoreDomains, icpState->request->host)) {
-           debug(33, 2, "clientProxyAuthCheck: host \"%s\" matched proxyAuthIgnoreDomains\n", icpState->request->host);
+       if (aclMatchRegex(Config.proxyAuth.IgnoreDomains, http->request->host)) {
+           debug(33, 2, "clientProxyAuthCheck: host \"%s\" matched proxyAuthIgnoreDomains\n", http->request->host);
            return 1;
        }
     }
-    proxy_user = proxyAuthenticate(icpState->request_hdr);
-    xstrncpy(icpState->ident.ident, proxy_user, ICP_IDENT_SZ);
-    debug(33, 6, "clientProxyAuthCheck: user = %s\n", icpState->ident.ident);
+    proxy_user = proxyAuthenticate(http->request_hdr);
+    xstrncpy(http->ident.ident, proxy_user, ICP_IDENT_SZ);
+    debug(33, 6, "clientProxyAuthCheck: user = %s\n", http->ident.ident);
 
-    if (strcmp(icpState->ident.ident, dash_str) == 0)
+    if (strcmp(http->ident.ident, dash_str) == 0)
        return 0;
     return 1;
 }
 #endif /* USE_PROXY_AUTH */
 
 static int
-checkAccelOnly(icpStateData * icpState)
+checkAccelOnly(clientHttpRequest * http)
 {
     /* return TRUE if someone makes a proxy request to us and
      * we are in httpd-accel only mode */
@@ -84,112 +77,114 @@ checkAccelOnly(icpStateData * icpState)
        return 0;
     if (Config.Accel.withProxy)
        return 0;
-    if (icpState->request->protocol == PROTO_CACHEOBJ)
+    if (http->request->protocol == PROTO_CACHEOBJ)
        return 0;
-    if (icpState->accel)
+    if (http->accel)
        return 0;
     return 1;
 }
 
 void
-clientAccessCheck(icpStateData * icpState, PF handler)
+clientAccessCheck(void *data)
 {
+    clientHttpRequest *http = data;
+    ConnStateData *conn = http->conn;
     char *browser;
-    if (Config.identLookup && icpState->ident.state == IDENT_NONE) {
-       icpState->aclHandler = handler;
-       identStart(-1, icpState, clientLookupIdentDone);
+    if (Config.identLookup && conn->ident.state == IDENT_NONE) {
+       identStart(-1, conn, clientAccessCheck);
        return;
     }
 #if USE_PROXY_AUTH
-    if (clientProxyAuthCheck(icpState) == 0) {
+    if (clientProxyAuthCheck(http) == 0) {
        char *wbuf = NULL;
-       int fd = icpState->fd;
-       debug(33, 4, "Proxy Denied: %s\n", icpState->url);
-       icpState->log_type = ERR_PROXY_DENIED;
-       icpState->http_code = 407;
-       wbuf = xstrdup(proxy_denied_msg(icpState->http_code,
-               icpState->method,
-               icpState->url,
+       int fd = conn->fd;
+       debug(33, 4, "Proxy Denied: %s\n", http->url);
+       http->log_type = ERR_PROXY_DENIED;
+       http->http_code = 407;
+       wbuf = xstrdup(proxy_denied_msg(http->http_code,
+               http->request->method,
+               http->url,
                fd_table[fd].ipaddr));
-       icpSendERROR(fd, icpState->log_type, wbuf, icpState, icpState->http_code);
-       safe_free(icpState->aclChecklist);
+       icpSendERROR(fd, http->log_type, wbuf, conn, http->http_code);
+       safe_free(http->aclChecklist);
        return;
     }
 #endif /* USE_PROXY_AUTH */
-    if (checkAccelOnly(icpState)) {
-       clientAccessCheckDone(0, icpState);
+    if (checkAccelOnly(http)) {
+       clientAccessCheckDone(0, http);
        return;
     }
-    browser = mime_get_header(icpState->request_hdr, "User-Agent");
-    icpState->acl_checklist = aclChecklistCreate(Config.accessList.HTTP,
-       icpState->request,
-       icpState->peer.sin_addr,
+    browser = mime_get_header(http->request_hdr, "User-Agent");
+    http->acl_checklist = aclChecklistCreate(Config.accessList.HTTP,
+       http->request,
+       conn->peer.sin_addr,
        browser,
-       icpState->ident.ident);
-    aclNBCheck(icpState->acl_checklist, handler, icpState);
+       conn->ident.ident);
+    aclNBCheck(http->acl_checklist, clientAccessCheckDone, http);
 }
 
 void
 clientAccessCheckDone(int answer, void *data)
 {
-    icpStateData *icpState = data;
-    int fd = icpState->fd;
+    clientHttpRequest *http = data;
+    ConnStateData *conn = http->conn;
+    int fd = conn->fd;
     char *buf = NULL;
     char *redirectUrl = NULL;
-    debug(33, 5, "clientAccessCheckDone: '%s' answer=%d\n", icpState->url, answer);
-    icpState->acl_checklist = NULL;
+    debug(33, 5, "clientAccessCheckDone: '%s' answer=%d\n", http->url, answer);
+    http->acl_checklist = NULL;
     if (answer) {
-       urlCanonical(icpState->request, icpState->url);
-       if (icpState->redirect_state != REDIRECT_NONE)
+       urlCanonical(http->request, http->url);
+       if (http->redirect_state != REDIRECT_NONE)
            fatal_dump("clientAccessCheckDone: wrong redirect_state");
-       icpState->redirect_state = REDIRECT_PENDING;
-       redirectStart(fd, icpState, clientRedirectDone, icpState);
+       http->redirect_state = REDIRECT_PENDING;
+       redirectStart(http, clientRedirectDone, http);
     } else {
-       debug(33, 5, "Access Denied: %s\n", icpState->url);
+       debug(33, 5, "Access Denied: %s\n", http->url);
        redirectUrl = aclGetDenyInfoUrl(&Config.denyInfoList, AclMatchedName);
        if (redirectUrl) {
-           icpState->http_code = 302,
-               buf = access_denied_redirect(icpState->http_code,
-               icpState->method,
-               icpState->url,
+           http->http_code = 302,
+               buf = access_denied_redirect(http->http_code,
+               http->request->method,
+               http->url,
                fd_table[fd].ipaddr,
                redirectUrl);
        } else {
-           icpState->http_code = 400;
-           buf = access_denied_msg(icpState->http_code,
-               icpState->method,
-               icpState->url,
+           http->http_code = 400;
+           buf = access_denied_msg(http->http_code,
+               http->request->method,
+               http->url,
                fd_table[fd].ipaddr);
        }
-       icpSendERROR(fd, LOG_TCP_DENIED, buf, icpState, icpState->http_code);
+       icpSendERROR(fd, LOG_TCP_DENIED, buf, http, http->http_code);
     }
 }
 
 static void
 clientRedirectDone(void *data, char *result)
 {
-    icpStateData *icpState = data;
-    int fd = icpState->fd;
+    clientHttpRequest *http = data;
+    int fd = http->conn->fd;
     request_t *new_request = NULL;
-    request_t *old_request = icpState->request;
-    debug(33, 5, "clientRedirectDone: '%s' result=%s\n", icpState->url,
+    request_t *old_request = http->request;
+    debug(33, 5, "clientRedirectDone: '%s' result=%s\n", http->url,
        result ? result : "NULL");
-    if (icpState->redirect_state != REDIRECT_PENDING)
+    if (http->redirect_state != REDIRECT_PENDING)
        fatal_dump("clientRedirectDone: wrong redirect_state");
-    icpState->redirect_state = REDIRECT_DONE;
+    http->redirect_state = REDIRECT_DONE;
     if (result)
        new_request = urlParse(old_request->method, result);
     if (new_request) {
-       safe_free(icpState->url);
-       icpState->url = xstrdup(result);
+       safe_free(http->url);
+       http->url = xstrdup(result);
        new_request->http_ver = old_request->http_ver;
        requestUnlink(old_request);
-       icpState->request = requestLink(new_request);
-       urlCanonical(icpState->request, icpState->url);
+       http->request = requestLink(new_request);
+       urlCanonical(http->request, http->url);
     }
-    icpParseRequestHeaders(icpState);
-    fd_note(fd, icpState->url);
-    icpProcessRequest(fd, icpState);
+    icpParseRequestHeaders(http);
+    fd_note(fd, http->url);
+    icpProcessRequest(fd, http);
 }
 
 #if USE_PROXY_AUTH
@@ -331,34 +326,34 @@ proxyAuthenticate(const char *headers)
 void
 icpProcessExpired(int fd, void *data)
 {
-    icpStateData *icpState = data;
-    char *url = icpState->url;
-    char *request_hdr = icpState->request_hdr;
+    clientHttpRequest *http = data;
+    char *url = http->url;
+    char *request_hdr = http->request_hdr;
     StoreEntry *entry = NULL;
 
-    debug(33, 3, "icpProcessExpired: FD %d '%s'\n", fd, icpState->url);
+    debug(33, 3, "icpProcessExpired: FD %d '%s'\n", fd, http->url);
 
-    BIT_SET(icpState->request->flags, REQ_REFRESH);
-    icpState->old_entry = icpState->entry;
+    BIT_SET(http->request->flags, REQ_REFRESH);
+    http->old_entry = http->entry;
     entry = storeCreateEntry(url,
        request_hdr,
-       icpState->req_hdr_sz,
-       icpState->request->flags,
-       icpState->method);
+       http->req_hdr_sz,
+       http->request->flags,
+       http->request->method);
     /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */
-    storeClientListAdd(entry, fd, 0);
-    storeClientListAdd(icpState->old_entry, fd, 0);
+    storeClientListAdd(entry, http, 0);
+    storeClientListAdd(http->old_entry, http, 0);
 
-    entry->lastmod = icpState->old_entry->lastmod;
+    entry->lastmod = http->old_entry->lastmod;
     debug(33, 5, "icpProcessExpired: setting lmt = %d\n",
        entry->lastmod);
 
     entry->refcount++;         /* EXPIRED CASE */
-    icpState->entry = entry;
-    icpState->out_offset = 0;
+    http->entry = entry;
+    http->out.offset = 0;
     /* Register with storage manager to receive updates when data comes in. */
-    storeRegister(entry, fd, icpHandleIMSReply, icpState);
-    protoDispatch(fd, icpState->entry, icpState->request);
+    storeRegister(entry, fd, icpHandleIMSReply, http);
+    protoDispatch(fd, http->entry, http->request);
 }
 
 static int
@@ -389,9 +384,11 @@ clientGetsOldEntry(StoreEntry * new_entry, StoreEntry * old_entry, request_t * r
 
 
 static void
-icpHandleIMSReply(int fd, StoreEntry * entry, void *data)
+icpHandleIMSReply(void *data)
 {
-    icpStateData *icpState = data;
+    clientHttpRequest *http = data;
+    int fd = http->conn->fd;
+    StoreEntry *entry = http->entry;
     MemObject *mem = entry->mem_obj;
     char *hbuf;
     int len;
@@ -404,34 +401,34 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data)
            log_tags[entry->mem_obj->abort_code], entry->url);
        /* We have an existing entry, but failed to validate it,
         * so send the old one anyway */
-       icpState->log_type = LOG_TCP_REFRESH_FAIL_HIT;
-       storeUnregister(entry, fd);
+       http->log_type = LOG_TCP_REFRESH_FAIL_HIT;
+       storeUnregister(entry, http);
        storeUnlockObject(entry);
-       icpState->entry = icpState->old_entry;
-       icpState->entry->refcount++;
+       http->entry = http->old_entry;
+       http->entry->refcount++;
     } else if (mem->reply->code == 0) {
        debug(33, 3, "icpHandleIMSReply: Incomplete headers for '%s'\n",
            entry->url);
        storeRegister(entry,
            fd,
            icpHandleIMSReply,
-           icpState);
+           http);
        return;
-    } else if (clientGetsOldEntry(entry, icpState->old_entry, icpState->request)) {
+    } else if (clientGetsOldEntry(entry, http->old_entry, http->request)) {
        /* We initiated the IMS request, the client is not expecting
         * 304, so put the good one back.  First, make sure the old entry
         * headers have been loaded from disk. */
-       oldentry = icpState->old_entry;
+       oldentry = http->old_entry;
        if (oldentry->mem_obj->e_current_len == 0) {
            storeRegister(entry,
                fd,
                icpHandleIMSReply,
-               icpState);
+               http);
            return;
        }
-       icpState->log_type = LOG_TCP_REFRESH_HIT;
+       http->log_type = LOG_TCP_REFRESH_HIT;
        hbuf = get_free_8k_page();
-       if (storeClientCopy(oldentry, 0, 8191, hbuf, &len, fd) < 0) {
+       if (storeClientCopy(oldentry, 0, 8191, hbuf, &len, http) < 0) {
            debug(33, 1, "icpHandleIMSReply: Couldn't copy old entry\n");
        } else {
            if (oldentry->mem_obj->request == NULL) {
@@ -439,9 +436,9 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data)
                unlink_request = 1;
            }
        }
-       storeUnregister(entry, fd);
+       storeUnregister(entry, http);
        storeUnlockObject(entry);
-       entry = icpState->entry = oldentry;
+       entry = http->entry = oldentry;
        if (mime_headers_end(hbuf)) {
            httpParseReplyHeaders(hbuf, entry->mem_obj->reply);
            storeTimestampsSet(entry);
@@ -457,17 +454,17 @@ icpHandleIMSReply(int fd, StoreEntry * entry, void *data)
        }
     } else {
        /* the client can handle this reply, whatever it is */
-       icpState->log_type = LOG_TCP_REFRESH_MISS;
+       http->log_type = LOG_TCP_REFRESH_MISS;
        if (mem->reply->code == 304) {
-           icpState->old_entry->timestamp = squid_curtime;
-           icpState->old_entry->refcount++;
-           icpState->log_type = LOG_TCP_REFRESH_HIT;
+           http->old_entry->timestamp = squid_curtime;
+           http->old_entry->refcount++;
+           http->log_type = LOG_TCP_REFRESH_HIT;
        }
-       storeUnregister(icpState->old_entry, fd);
-       storeUnlockObject(icpState->old_entry);
+       storeUnregister(http->old_entry, http);
+       storeUnlockObject(http->old_entry);
     }
-    icpState->old_entry = NULL;        /* done with old_entry */
-    icpSendMoreData(fd, icpState);     /* give data to the client */
+    http->old_entry = NULL;    /* done with old_entry */
+    icpSendMoreData(fd, http); /* give data to the client */
 }
 
 int
@@ -502,7 +499,7 @@ modifiedSince(StoreEntry * entry, request_t * request)
 }
 
 char *
-clientConstructTraceEcho(icpStateData * icpState)
+clientConstructTraceEcho(clientHttpRequest * http)
 {
     LOCAL_ARRAY(char, line, 256);
     LOCAL_ARRAY(char, buf, 8192);
@@ -517,44 +514,44 @@ clientConstructTraceEcho(icpStateData * icpState)
     strcat(buf, line);
     strcat(buf, "\r\n");
     len = strlen(buf);
-    httpBuildRequestHeader(icpState->request,
-       icpState->request,
+    httpBuildRequestHeader(http->request,
+       http->request,
        NULL,                   /* entry */
-       icpState->request_hdr,
+       http->request_hdr,
        NULL,                   /* in_len */
        buf + len,
        8192 - len,
-       icpState->fd);
-    icpState->log_type = LOG_TCP_MISS;
-    icpState->http_code = 200;
+       http->conn->fd);
+    http->log_type = LOG_TCP_MISS;
+    http->http_code = 200;
     return buf;
 }
 
 void
-clientPurgeRequest(icpStateData * icpState)
+clientPurgeRequest(clientHttpRequest * http)
 {
     char *buf;
-    int fd = icpState->fd;
+    int fd = http->conn->fd;
     LOCAL_ARRAY(char, msg, 8192);
     LOCAL_ARRAY(char, line, 256);
     StoreEntry *entry;
     debug(0, 0, "Config.Options.enable_purge = %d\n", Config.Options.enable_purge);
     if (!Config.Options.enable_purge) {
-       buf = access_denied_msg(icpState->http_code = 401,
-           icpState->method,
-           icpState->url,
+       buf = access_denied_msg(http->http_code = 401,
+           http->request->method,
+           http->url,
            fd_table[fd].ipaddr);
-       icpSendERROR(fd, LOG_TCP_DENIED, buf, icpState, icpState->http_code);
+       icpSendERROR(fd, LOG_TCP_DENIED, buf, http, http->http_code);
        return;
     }
-    icpState->log_type = LOG_TCP_MISS;
-    if ((entry = storeGet(icpState->url)) == NULL) {
+    http->log_type = LOG_TCP_MISS;
+    if ((entry = storeGet(http->url)) == NULL) {
        sprintf(msg, "HTTP/1.0 404 Not Found\r\n");
-       icpState->http_code = 404;
+       http->http_code = 404;
     } else {
        storeRelease(entry);
        sprintf(msg, "HTTP/1.0 200 OK\r\n");
-       icpState->http_code = 200;
+       http->http_code = 200;
     }
     sprintf(line, "Date: %s\r\n", mkrfc1123(squid_curtime));
     strcat(msg, line);
@@ -565,6 +562,6 @@ clientPurgeRequest(icpStateData * icpState)
        msg,
        strlen(msg),
        icpSendERRORComplete,
-       icpState,
+       http,
        NULL);
 }
index 60bd4aa8cc7625fd78ada9780d5a981e81fa847d..07290e4b594967351b0a14983920c1ec70415819 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.159 1997/05/05 03:43:44 wessels Exp $
+ * $Id: http.cc,v 1.160 1997/05/08 07:22:02 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -814,7 +814,7 @@ httpSendRequest(int fd, void *data)
     else if (entry->mem_obj == NULL)
        cfd = -1;
     else
-       cfd = storeFirstClientFD(entry->mem_obj);
+       cfd = entry->mem_obj->fd;
     len = httpBuildRequestHeader(req,
        httpState->orig_request ? httpState->orig_request : req,
        entry,
index 03eff38c5ce4a5e8b3b388b5b437e10090e2bffb..0edfc4da1fd6d10fdc1e6e22e15b3a4e022cfe97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ident.cc,v 1.28 1997/04/30 18:30:55 wessels Exp $
+ * $Id: ident.cc,v 1.29 1997/05/08 07:22:05 wessels Exp $
  *
  * DEBUG: section 30    Ident (RFC 931)
  * AUTHOR: Duane Wessels
 
 #define IDENT_PORT 113
 
-static void identRequestComplete _PARAMS((int, char *, int, int, void *));
+static CWCB identRequestComplete;
 static PF identReadReply;
 static PF identClose;
 static CNCB identConnectDone;
-static void identCallback _PARAMS((icpStateData * icpState));
+static void identCallback _PARAMS((ConnStateData * connState));
 
 static void
 identClose(int fd, void *data)
 {
-    icpStateData *icpState = data;
-    icpState->ident.fd = -1;
+    ConnStateData *connState = data;
+    connState->ident.fd = -1;
 }
 
 /* start a TCP connection to the peer host on port 113 */
 void
-identStart(int fd, icpStateData * icpState, void (*callback) _PARAMS((void *)))
+identStart(int fd, ConnStateData * connState, IDCB * callback)
 {
-    icpState->ident.callback = callback;
-    icpState->ident.state = IDENT_PENDING;
+    connState->ident.callback = callback;
+    connState->ident.state = IDENT_PENDING;
     if (fd < 0) {
        fd = comm_open(SOCK_STREAM,
            0,
-           icpState->me.sin_addr,
+           connState->me.sin_addr,
            0,
            COMM_NONBLOCKING,
            "ident");
        if (fd == COMM_ERROR) {
-           identCallback(icpState);
+           identCallback(connState);
            return;
        }
     }
-    icpState->ident.fd = fd;
+    connState->ident.fd = fd;
     comm_add_close_handler(fd,
        identClose,
-       icpState);
+       connState);
     commConnectStart(fd,
-       inet_ntoa(icpState->peer.sin_addr),
+       inet_ntoa(connState->peer.sin_addr),
        IDENT_PORT,
        identConnectDone,
-       icpState);
+       connState);
 }
 
 static void
 identConnectDone(int fd, int status, void *data)
 {
-    icpStateData *icpState = data;
+    ConnStateData *connState = data;
     LOCAL_ARRAY(char, reqbuf, BUFSIZ);
     if (status == COMM_ERROR) {
        comm_close(fd);
-       identCallback(icpState);
+       identCallback(connState);
        return;
     }
     sprintf(reqbuf, "%d, %d\r\n",
-       ntohs(icpState->peer.sin_port),
-       ntohs(icpState->me.sin_port));
+       ntohs(connState->peer.sin_port),
+       ntohs(connState->me.sin_port));
     comm_write(fd,
        reqbuf,
        strlen(reqbuf),
        identRequestComplete,
-       icpState,
+       connState,
        NULL);
     commSetSelect(fd,
        COMM_SELECT_READ,
        identReadReply,
-       icpState, 0);
+       connState, 0);
 }
 
 static void
@@ -108,7 +108,7 @@ identRequestComplete(int fd, char *buf, int size, int errflag, void *data)
 static void
 identReadReply(int fd, void *data)
 {
-    icpStateData *icpState = data;
+    ConnStateData *connState = data;
     LOCAL_ARRAY(char, buf, BUFSIZ);
     char *t = NULL;
     int len = -1;
@@ -125,18 +125,18 @@ identReadReply(int fd, void *data)
        if (strstr(buf, "USERID")) {
            if ((t = strrchr(buf, ':'))) {
                while (isspace(*++t));
-               xstrncpy(icpState->ident.ident, t, ICP_IDENT_SZ);
+               xstrncpy(connState->ident.ident, t, ICP_IDENT_SZ);
            }
        }
     }
     comm_close(fd);
-    identCallback(icpState);
+    identCallback(connState);
 }
 
 static void
-identCallback(icpStateData * icpState)
+identCallback(ConnStateData * connState)
 {
-    icpState->ident.state = IDENT_DONE;
-    if (icpState->ident.callback)
-       icpState->ident.callback(icpState);
+    connState->ident.state = IDENT_DONE;
+    if (connState->ident.callback)
+       connState->ident.callback(connState);
 }
index ba6d41166c0b30fc42c23ebadfd7b883b57ba955..884d19ffa9e41b8b787497186a77bde0807a4c6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: redirect.cc,v 1.41 1997/05/05 03:43:48 wessels Exp $
+ * $Id: redirect.cc,v 1.42 1997/05/08 07:22:06 wessels Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -35,7 +35,6 @@
 #define REDIRECT_FLAG_CLOSING          0x04
 
 typedef struct {
-    int fd;
     void *data;
     char *orig_url;
     struct in_addr client_addr;
@@ -328,29 +327,29 @@ redirectDispatch(redirector_t * redirect, redirectStateData * r)
 
 
 void
-redirectStart(int cfd, icpStateData * icpState, RH * handler, void *data)
+redirectStart(clientHttpRequest * http, RH * handler, void *data)
 {
+    ConnStateData *conn = http->conn;
     redirectStateData *r = NULL;
     redirector_t *redirector = NULL;
-    debug(29, 5, "redirectStart: '%s'\n", icpState->url);
+    if (!http)
+       fatal_dump("redirectStart: NULL clientHttpRequest");
     if (!handler)
        fatal_dump("redirectStart: NULL handler");
-    if (!icpState)
-       fatal_dump("redirectStart: NULL icpState");
+    debug(29, 5, "redirectStart: '%s'\n", http->url);
     if (Config.Program.redirect == NULL) {
        handler(data, NULL);
        return;
     }
     r = xcalloc(1, sizeof(redirectStateData));
-    r->fd = cfd;
-    r->orig_url = xstrdup(icpState->url);
-    r->client_addr = icpState->log_addr;
-    if (icpState->ident.ident == NULL || *icpState->ident.ident == '\0') {
+    r->orig_url = xstrdup(http->url);
+    r->client_addr = conn->log_addr;
+    if (conn->ident.ident == NULL || *conn->ident.ident == '\0') {
        r->client_ident = dash_str;
     } else {
-       r->client_ident = icpState->ident.ident;
+       r->client_ident = conn->ident.ident;
     }
-    r->method_s = RequestMethodStr[icpState->request->method];
+    r->method_s = RequestMethodStr[http->request->method];
     r->handler = handler;
     r->data = data;
     if ((redirector = GetFirstAvailable()))
@@ -458,7 +457,7 @@ redirectShutdownServers(void)
 
 
 int
-redirectUnregister(const char *url, int fd)
+redirectUnregister(const char *url, void *data)
 {
     redirector_t *redirect = NULL;
     redirectStateData *r = NULL;
@@ -467,12 +466,12 @@ redirectUnregister(const char *url, int fd)
     int n = 0;
     if (Config.Program.redirect == NULL)
        return 0;
-    debug(29, 3, "redirectUnregister: FD %d '%s'\n", fd, url);
+    debug(29, 3, "redirectUnregister: '%s'\n", url);
     for (k = 0; k < NRedirectors; k++) {
        redirect = *(redirect_child_table + k);
        if ((r = redirect->redirectState) == NULL)
            continue;
-       if (r->fd != fd)
+       if (r->data != data)
            continue;
        if (strcmp(r->orig_url, url))
            continue;
@@ -483,7 +482,7 @@ redirectUnregister(const char *url, int fd)
     for (rq = redirectQueueHead; rq; rq = rq->next) {
        if ((r = rq->redirectState) == NULL)
            continue;
-       if (r->fd != fd)
+       if (r->data != data)
            continue;
        if (strcmp(r->orig_url, url))
            continue;
index 3f49d6aabbe320ee7747bf54460dcd1b3bdbb150..1cdb2db9b08a0c55bb9ad1eabfe1708a19bdcab1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.108 1997/05/02 21:34:13 wessels Exp $
+ * $Id: squid.h,v 1.109 1997/05/08 07:22:07 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -364,7 +364,7 @@ extern int passStart _PARAMS((int fd,
        char *buf,
        int buflen,
        int *size_ptr));
-extern void identStart _PARAMS((int, icpStateData *,
+extern void identStart _PARAMS((int, ConnStateData *,
        void       (*callback) _PARAMS((void *))));
 extern int httpAnonAllowed _PARAMS((const char *line));
 extern int httpAnonDenied _PARAMS((const char *line));
index 90b921f799ac9833ec01e2abcdbcff150a192cfb..74fb5be78de86ee9289704e9fb40c52dcbd87503 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.48 1997/04/30 20:06:36 wessels Exp $
+ * $Id: ssl.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -44,7 +44,7 @@ typedef struct {
        char *buf;
     } client, server;
     time_t timeout;
-    int *size_ptr;             /* pointer to size in an icpStateData for logging */
+    int *size_ptr;             /* pointer to size in an ConnStateData for logging */
     int proxying;
     int ip_lookup_pending;
 } SslStateData;
index 37eaad0a0a97071397fd5caaa382b54e0bb690a6..1374b084ef4ae8caf1756360f07fa6bbe9a5d444 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.229 1997/05/05 03:43:49 wessels Exp $
+ * $Id: store.cc,v 1.230 1997/05/08 07:22:08 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -254,7 +254,7 @@ static int compareSize _PARAMS((StoreEntry **, StoreEntry **));
 static int compareBucketOrder _PARAMS((struct _bucketOrder *, struct _bucketOrder *));
 static int storeCheckExpired _PARAMS((const StoreEntry *, int flag));
 static int storeCheckPurgeMem _PARAMS((const StoreEntry *));
-static int storeClientListSearch _PARAMS((const MemObject *, int));
+static int storeClientListSearch _PARAMS((const MemObject *, void *));
 static int storeCopy _PARAMS((const StoreEntry *, int, int, char *, int *));
 static void storeLockObjectComplete _PARAMS((void *, int));
 static int storeEntryLocked _PARAMS((const StoreEntry *));
@@ -841,8 +841,6 @@ storeCreateEntry(const char *url,
     /* allocate client list */
     mem->nclients = MIN_CLIENT;
     mem->clients = xcalloc(mem->nclients, sizeof(struct _store_client));
-    for (i = 0; i < mem->nclients; i++)
-       mem->clients[i].fd = -1;
     /* storeLog(STORE_LOG_CREATE, e); */
     return e;
 }
@@ -895,12 +893,12 @@ storeAddDiskRestore(const char *url, int file_number, int size, time_t expires,
 
 /* Register interest in an object currently being retrieved. */
 int
-storeRegister(StoreEntry * e, int fd, PIF * handler, void *data)
+storeRegister(StoreEntry * e, int fd, STCB * handler, void *data)
 {
     int i;
     MemObject *mem = e->mem_obj;
     debug(20, 3, "storeRegister: FD %d '%s'\n", fd, e->key);
-    if ((i = storeClientListSearch(mem, fd)) < 0)
+    if ((i = storeClientListSearch(mem, data)) < 0)
        i = storeClientListAdd(e, fd, 0);
     if (mem->clients[i].callback)
        fatal_dump("storeRegister: handler already exists");
@@ -910,16 +908,15 @@ storeRegister(StoreEntry * e, int fd, PIF * handler, void *data)
 }
 
 int
-storeUnregister(StoreEntry * e, int fd)
+storeUnregister(StoreEntry * e, void *data)
 {
     int i;
     MemObject *mem = e->mem_obj;
     if (mem == NULL)
        return 0;
-    debug(20, 3, "storeUnregister: called for FD %d '%s'\n", fd, e->key);
-    if ((i = storeClientListSearch(mem, fd)) < 0)
+    debug(20, 3, "storeUnregister: called for '%s'\n", e->key);
+    if ((i = storeClientListSearch(mem, data)) < 0)
        return 0;
-    mem->clients[i].fd = -1;
     mem->clients[i].last_offset = 0;
     mem->clients[i].callback = NULL;
     mem->clients[i].callback_data = NULL;
@@ -934,7 +931,7 @@ storeGetLowestReaderOffset(const StoreEntry * entry)
     int lowest = mem->e_current_len;
     int i;
     for (i = 0; i < mem->nclients; i++) {
-       if (mem->clients[i].fd == -1)
+       if (mem->clients[i].callback_data == NULL)
            continue;
        if (mem->clients[i].last_offset < lowest)
            lowest = mem->clients[i].last_offset;
@@ -965,7 +962,7 @@ InvokeHandlers(StoreEntry * e)
 {
     int i;
     MemObject *mem = e->mem_obj;
-    PIF *handler = NULL;
+    STCB *handler = NULL;
     void *data = NULL;
     struct _store_client *sc;
     if (mem->clients == NULL && mem->nclients) {
@@ -975,14 +972,14 @@ InvokeHandlers(StoreEntry * e)
     /* walk the entire list looking for valid handlers */
     for (i = 0; i < mem->nclients; i++) {
        sc = &mem->clients[i];
-       if (sc->fd == -1)
+       if (sc->callback_data == NULL)
            continue;
        if ((handler = sc->callback) == NULL)
            continue;
        data = sc->callback_data;
        sc->callback = NULL;
-       sc->callback_data = NULL;
-       handler(sc->fd, e, data);
+       /* Don't NULL the callback_data, its used to identify the client */
+       handler(data);
     }
 }
 
@@ -2243,7 +2240,7 @@ storeClientWaiting(const StoreEntry * e)
     MemObject *mem = e->mem_obj;
     if (mem->clients) {
        for (i = 0; i < mem->nclients; i++) {
-           if (mem->clients[i].fd != -1)
+           if (mem->clients[i].callback_data != NULL)
                return 1;
        }
     }
@@ -2251,14 +2248,12 @@ storeClientWaiting(const StoreEntry * e)
 }
 
 static int
-storeClientListSearch(const MemObject * mem, int fd)
+storeClientListSearch(const MemObject * mem, void *data)
 {
     int i;
     if (mem->clients) {
        for (i = 0; i < mem->nclients; i++) {
-           if (mem->clients[i].fd == -1)
-               continue;
-           if (mem->clients[i].fd != fd)
+           if (mem->clients[i].callback_data != data)
                continue;
            return i;
        }
@@ -2268,7 +2263,7 @@ storeClientListSearch(const MemObject * mem, int fd)
 
 /* add client with fd to client list */
 int
-storeClientListAdd(StoreEntry * e, int fd, int last_offset)
+storeClientListAdd(StoreEntry * e, void *data, int last_offset)
 {
     int i;
     MemObject *mem = e->mem_obj;
@@ -2278,30 +2273,25 @@ storeClientListAdd(StoreEntry * e, int fd, int last_offset)
     if (mem->clients == NULL) {
        mem->nclients = MIN_CLIENT;
        mem->clients = xcalloc(mem->nclients, sizeof(struct _store_client));
-       for (i = 0; i < mem->nclients; i++)
-           mem->clients[i].fd = -1;
     }
     for (i = 0; i < mem->nclients; i++) {
-       if (mem->clients[i].fd == fd)
+       if (mem->clients[i].callback_data == data)
            return i;           /* its already here */
-       if (mem->clients[i].fd == -1)
+       if (mem->clients[i].callback_data == NULL)
            break;
     }
     if (i == mem->nclients) {
-       debug(20, 3, "storeClientListAdd: FD %d Growing clients for '%s'\n",
-           fd, e->url);
+       debug(20, 3, "storeClientListAdd: Growing clients for '%s'\n", e->url);
        oldlist = mem->clients;
        oldsize = mem->nclients;
        mem->nclients <<= 1;
        mem->clients = xcalloc(mem->nclients, sizeof(struct _store_client));
        for (i = 0; i < oldsize; i++)
            mem->clients[i] = oldlist[i];
-       for (; i < mem->nclients; i++)
-           mem->clients[i].fd = -1;
        safe_free(oldlist);
        i = oldsize;
     }
-    mem->clients[i].fd = fd;
+    mem->clients[i].callback_data = data;
     mem->clients[i].last_offset = last_offset;
     return i;
 }
@@ -2314,7 +2304,7 @@ storeClientCopy(StoreEntry * e,
     int maxSize,
     char *buf,
     int *size,
-    int fd)
+    void *data)
 {
     int ci;
     int sz;
@@ -2328,7 +2318,7 @@ storeClientCopy(StoreEntry * e,
        *size = 0;
        return 0;
     }
-    if ((ci = storeClientListSearch(mem, fd)) < 0) {
+    if ((ci = storeClientListSearch(mem, data)) < 0) {
        debug_trap("storeClientCopy: Unregistered client");
        debug(20, 0, "--> '%s'\n", e->url);
        *size = 0;
@@ -2693,7 +2683,7 @@ storePendingNClients(const StoreEntry * e)
     if (mem == NULL)
        return 0;
     for (i = 0; i < mem->nclients; i++) {
-       if (mem->clients[i].fd == -1)
+       if (mem->clients[i].callback_data == NULL)
            continue;
        npend++;
     }
@@ -2890,21 +2880,6 @@ storeEntryValidToSend(StoreEntry * e)
     return 1;
 }
 
-int
-storeFirstClientFD(MemObject * mem)
-{
-    int i;
-    if (mem == NULL)
-       return -1;
-    if (mem->clients == NULL)
-       return -1;
-    for (i = 0; i < mem->nclients; i++) {
-       if (mem->clients[i].fd > -1)
-           return mem->clients[i].fd;
-    }
-    return -1;
-}
-
 void
 storeTimestampsSet(StoreEntry * entry)
 {
index e098f13fc07bed3fd747936a14239c51cb9c94d1..4c8aba2117c389d2e7cdca271119e00bb64cfa98 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.48 1997/04/30 20:06:36 wessels Exp $
+ * $Id: tunnel.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -44,7 +44,7 @@ typedef struct {
        char *buf;
     } client, server;
     time_t timeout;
-    int *size_ptr;             /* pointer to size in an icpStateData for logging */
+    int *size_ptr;             /* pointer to size in an ConnStateData for logging */
     int proxying;
     int ip_lookup_pending;
 } SslStateData;