]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
-Changed comm_write() to free/give up memory after the write has been
authorwessels <>
Sat, 20 Jul 1996 09:16:49 +0000 (09:16 +0000)
committerwessels <>
Sat, 20 Jul 1996 09:16:49 +0000 (09:16 +0000)
 called.  Removed most of the 'page_ptr' cruft in other data strucutres.
-Combined hierarchy.log into access.log
-Changed some stray comm_write()'s into icpSendERROR()'s

15 files changed:
src/comm.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/ident.cc
src/ipcache.cc
src/neighbors.cc
src/redirect.cc
src/squid.h
src/ssl.cc
src/stat.cc
src/stmem.cc
src/store.cc
src/tunnel.cc
src/wais.cc

index d2a09d2cc4f01ed0b7e25bcb39ee9ab9478f987a..9a7e523e9aae6a1d3e7c03c4eea61e1e5d225201 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.40 1996/07/19 17:37:39 wessels Exp $
+ * $Id: comm.cc,v 1.41 1996/07/20 03:16:49 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -129,6 +129,7 @@ struct _RWStateData {
     rw_complete_handler *handler;
     void *handler_data;
     int handle_immed;
+    void (*free)(void *);
 };
 
 /* GLOBAL */
@@ -143,6 +144,7 @@ static int examine_select _PARAMS((fd_set *, fd_set *, fd_set *));
 static void commSetNoLinger _PARAMS((int));
 static void comm_select_incoming _PARAMS((void));
 static int commBind _PARAMS((int s, struct in_addr, u_short port));
+static void RWStateFree _PARAMS((int fd, RWStateData *, int code));
 #ifdef TCP_NODELAY
 static void commSetTcpNoDelay _PARAMS((int));
 #endif
@@ -150,28 +152,53 @@ static void commSetTcpNoDelay _PARAMS((int));
 static int *fd_lifetime = NULL;
 static struct timeval zero_tv;
 
+static void RWStateFree(fd, RWState, code)
+     int fd;
+     RWStateData *RWState;
+     int code;
+{
+    rw_complete_handler *callback = NULL;
+    if (RWState == NULL)
+       return;
+    if (RWState->free) {
+       RWState->free(RWState->buf);
+       RWState->buf = NULL;
+    }
+    callback = RWState->handler;
+    RWState->handler = NULL;
+    if (callback) {
+       callback(fd,
+           RWState->buf,
+           RWState->offset,
+           code,
+           RWState->handler_data);
+    }
+    safe_free(RWState);
+}
+
 /* Return the local port associated with fd. */
 u_short comm_local_port(fd)
      int fd;
 {
     struct sockaddr_in addr;
     int addr_len = 0;
+    FD_ENTRY *fde = &fd_table[fd];
 
     /* If the fd is closed already, just return */
-    if (!fd_table[fd].openned) {
+    if (!fde->openned) {
        debug(5, 0, "comm_local_port: FD %d has been closed.\n", fd);
        return 0;
     }
-    if (fd_table[fd].local_port)
-       return fd_table[fd].local_port;
+    if (fde->local_port)
+       return fde->local_port;
     addr_len = sizeof(addr);
     if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) {
        debug(5, 1, "comm_local_port: Failed to retrieve TCP/UDP port number for socket: FD %d: %s\n", fd, xstrerror());
        return 0;
     }
     debug(5, 6, "comm_local_port: FD %d: sockaddr %u.\n", fd, addr.sin_addr.s_addr);
-    fd_table[fd].local_port = ntohs(addr.sin_port);
-    return fd_table[fd].local_port;
+    fde->local_port = ntohs(addr.sin_port);
+    return fde->local_port;
 }
 
 static int commBind(s, in_addr, port)
@@ -450,32 +477,33 @@ int comm_accept(fd, peer, me)
     return sock;
 }
 
-int comm_close(fd)
+void comm_close(fd)
      int fd;
 {
     FD_ENTRY *conn = NULL;
     struct close_handler *ch = NULL;
     debug(5, 5, "comm_close: FD %d\n", fd);
-    if (fd < 0)
-       return -1;
+    if (fd < 0 || fd >= FD_SETSIZE)
+       return;
+    conn = &fd_table[fd];
+    if (!conn->openned)
+       return;
     if (fdstatGetType(fd) == FD_FILE) {
        debug(5, 0, "FD %d: Someone called comm_close() on a File\n", fd);
        fatal_dump(NULL);
     }
-    conn = &fd_table[fd];
-    safe_free(conn->rstate);
-    safe_free(conn->wstate);
+    conn->openned = 0;
+    RWStateFree(fd, conn->rstate, COMM_ERROR);
+    RWStateFree(fd, conn->wstate, COMM_ERROR);
     comm_set_fd_lifetime(fd, -1);      /* invalidate the lifetime */
-    /* update fdstat */
-    fdstat_close(fd);
-    /* Call close handlers */
-    while ((ch = conn->close_handler)) {
+    fdstat_close(fd);                  /* update fdstat */
+    while ((ch = conn->close_handler)) { /* Call close handlers */
        conn->close_handler = ch->next;
        ch->handler(fd, ch->data);
        safe_free(ch);
     }
     memset(conn, '\0', sizeof(FD_ENTRY));
-    return close(fd);
+    close(fd);
 }
 
 /* use to clean up fdtable when socket is closed without
@@ -484,8 +512,8 @@ int comm_cleanup_fd_entry(fd)
      int fd;
 {
     FD_ENTRY *conn = &fd_table[fd];
-    safe_free(conn->rstate);
-    safe_free(conn->wstate);
+    RWStateFree(fd, conn->rstate, COMM_ERROR);
+    RWStateFree(fd, conn->wstate, COMM_ERROR);
     memset(conn, 0, sizeof(FD_ENTRY));
     return 0;
 }
@@ -1114,6 +1142,7 @@ static void checkLifetimes()
 {
     int fd;
     time_t lft;
+    FD_ENTRY *fde = NULL;
 
     int (*func) () = NULL;
 
@@ -1123,28 +1152,29 @@ static void checkLifetimes()
        if (lft > squid_curtime)
            continue;
        debug(5, 5, "checkLifetimes: FD %d Expired\n", fd);
-       if ((func = fd_table[fd].lifetime_handler)) {
+       fde = &fd_table[fd];
+       if ((func = fde->lifetime_handler)) {
            debug(5, 5, "checkLifetimes: FD %d: Calling lifetime handler\n", fd);
-           func(fd, fd_table[fd].lifetime_data);
-           fd_table[fd].lifetime_handler = NULL;
-       } else if ((func = fd_table[fd].read_handler)) {
+           func(fd, fde->lifetime_data);
+           fde->lifetime_handler = NULL;
+       } else if ((func = fde->read_handler)) {
            debug(5, 5, "checkLifetimes: FD %d: Calling read handler\n", fd);
-           func(fd, fd_table[fd].read_data);
-           fd_table[fd].read_handler = NULL;
-       } else if ((func = fd_table[fd].read_handler)) {
+           func(fd, fde->read_data);
+           fde->read_handler = NULL;
+       } else if ((func = fde->read_handler)) {
            debug(5, 5, "checkLifetimes: FD %d: Calling read handler\n", fd);
-           func(fd, fd_table[fd].read_data);
-           fd_table[fd].read_handler = NULL;
-       } else if ((func = fd_table[fd].write_handler)) {
+           func(fd, fde->read_data);
+           fde->read_handler = NULL;
+       } else if ((func = fde->write_handler)) {
            debug(5, 5, "checkLifetimes: FD %d: Calling write handler\n", fd);
-           func(fd, fd_table[fd].write_data);
-           fd_table[fd].write_handler = NULL;
+           func(fd, fde->write_data);
+           fde->write_handler = NULL;
        } else {
            debug(5, 5, "checkLifetimes: FD %d: No handlers, calling comm_close()\n", fd);
            comm_close(fd);
            comm_cleanup_fd_entry(fd);
        }
-       if (fd_table[fd].openned) {
+       if (fde->openned) {
            /* still opened */
            debug(5, 5, "checkLifetimes: FD %d: Forcing comm_close()\n", fd);
            comm_close(fd);
@@ -1193,30 +1223,20 @@ static int commHandleRead(fd, state)
     debug(5, 5, "commHandleRead: FD %d: read %d bytes\n", fd, len);
 
     if (len <= 0) {
-       switch (errno) {
-#if EAGAIN != EWOULDBLOCK
-       case EAGAIN:
-#endif
-       case EWOULDBLOCK:
+       if (errno == EWOULDBLOCK || errno == EAGAIN) {
            /* reschedule self */
            comm_set_select_handler(fd,
                COMM_SELECT_READ,
                (PF) commHandleRead,
                state);
            return COMM_OK;
-       default:
+       } else {
            /* Len == 0 means connection closed; otherwise would not have been
             * called by comm_select(). */
            debug(5, len == 0 ? 2 : 1, "commHandleRead: FD %d: read failure: %s\n",
                fd, len == 0 ? "connection closed" : xstrerror());
            fd_table[fd].rstate = NULL;         /* The handler may issue a new read */
-           /* Notify caller that we failed */
-           state->handler(fd,
-               state->buf,
-               state->offset,
-               COMM_ERROR,
-               state->handler_data);
-           safe_free(state);
+           RWStateFree(fd, state, COMM_ERROR);
            return COMM_ERROR;
        }
     }
@@ -1225,12 +1245,7 @@ static int commHandleRead(fd, state)
     /* Call handler if we have read enough */
     if (state->offset >= state->size || state->handle_immed) {
        fd_table[fd].rstate = NULL;     /* The handler may issue a new read */
-       state->handler(fd,
-           state->buf,
-           state->offset,
-           COMM_OK,
-           state->handler_data);
-       safe_free(state);
+       RWStateFree(fd, state, COMM_OK);
     } else {
        /* Reschedule until we are done */
        comm_set_select_handler(fd,
@@ -1271,6 +1286,7 @@ void comm_read(fd, buf, size, timeout, immed, handler, handler_data)
     state->handle_immed = immed;
     state->time = squid_curtime;
     state->handler_data = handler_data;
+    state->free = NULL;
     comm_set_select_handler(fd,
        COMM_SELECT_READ,
        (PF) commHandleRead,
@@ -1297,45 +1313,22 @@ static void commHandleWrite(fd, state)
        if (nleft != 0)
            debug(5, 2, "commHandleWrite: FD %d: write failure: connection closed with %d bytes remaining.\n", fd, nleft);
        fd_table[fd].wstate = NULL;
-       if (state->handler)
-           state->handler(fd,
-               state->buf,
-               state->offset,
-               nleft ? COMM_ERROR : COMM_OK,
-               state->handler_data);
-       else
-           xfree(state->buf);
-       safe_free(state);
-       return;
+       RWStateFree(fd, state, nleft ? COMM_ERROR : COMM_OK);
     } else if (len < 0) {
        /* An error */
        if (errno == EWOULDBLOCK || errno == EAGAIN) {
-           /* XXX: Re-install the handler rather than giving up. I hope
-            * this doesn't freeze this socket due to some random OS bug
-            * returning EWOULDBLOCK indefinitely.  Ought to maintain a
-            * retry count in state? */
            debug(5, 10, "commHandleWrite: FD %d: write failure: %s.\n",
                fd, xstrerror());
            comm_set_select_handler(fd,
                COMM_SELECT_WRITE,
                (PF) commHandleWrite,
                state);
-           return;
+       } else {
+           debug(5, 2, "commHandleWrite: FD %d: write failure: %s.\n",
+               fd, xstrerror());
+           fd_table[fd].wstate = NULL;
+           RWStateFree(fd, state, COMM_ERROR);
        }
-       debug(5, 2, "commHandleWrite: FD %d: write failure: %s.\n",
-           fd, xstrerror());
-       /* Notify caller that we failed */
-       fd_table[fd].wstate = NULL;
-       if (state->handler)
-           state->handler(fd,
-               state->buf,
-               state->offset,
-               COMM_ERROR,
-               state->handler_data);
-       else
-           xfree(state->buf);
-       safe_free(state);
-       return;
     } else {
        /* A successful write, continue */
        state->offset += len;
@@ -1345,19 +1338,10 @@ static void commHandleWrite(fd, state)
                COMM_SELECT_WRITE,
                (PF) commHandleWrite,
                state);
-           return;
+       } else {
+           fd_table[fd].wstate = NULL;
+           RWStateFree(fd, state, COMM_OK);
        }
-       fd_table[fd].wstate = NULL;
-       /* Notify caller that the write is complete */
-       if (state->handler)
-           state->handler(fd,
-               state->buf,
-               state->offset,
-               COMM_OK,
-               state->handler_data);
-       else
-           xfree(state->buf);
-       safe_free(state);
     }
 }
 
@@ -1365,13 +1349,14 @@ static void commHandleWrite(fd, state)
 
 /* Select for Writing on FD, until SIZE bytes are sent.  Call
  * * HANDLER when complete. */
-void comm_write(fd, buf, size, timeout, handler, handler_data)
+void comm_write(fd, buf, size, timeout, handler, handler_data, free)
      int fd;
      char *buf;
      int size;
      int timeout;
      rw_complete_handler *handler;
      void *handler_data;
+     void (*free)(void *);
 {
     RWStateData *state = NULL;
 
@@ -1380,7 +1365,7 @@ void comm_write(fd, buf, size, timeout, handler, handler_data)
 
     if (fd_table[fd].wstate) {
        debug(5, 1, "comm_write: WARNING! FD %d: A comm_write is already active.\n", fd);
-       safe_free(fd_table[fd].wstate);
+       RWStateFree(fd, fd_table[fd].wstate, COMM_ERROR);
     }
     state = xcalloc(1, sizeof(RWStateData));
     state->buf = buf;
@@ -1390,6 +1375,7 @@ void comm_write(fd, buf, size, timeout, handler, handler_data)
     state->timeout = timeout;
     state->time = squid_curtime;
     state->handler_data = handler_data;
+    state->free = free;
     comm_set_select_handler(fd,
        COMM_SELECT_WRITE,
        (PF) commHandleWrite,
index 890e00b77e045153e3c118d310380afed600f889..d14f8d802d05f63f03d39f8b09caa820fb1e9fd6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.45 1996/07/19 17:38:36 wessels Exp $
+ * $Id: ftp.cc,v 1.46 1996/07/20 03:16:50 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -121,9 +121,6 @@ typedef struct _Ftpdata {
     char password[MAX_URL];
     char *reply_hdr;
     int ftp_fd;
-    char *icp_page_ptr;                /* Used to send proxy-http request: 
-                                * put_free_8k_page(me) if the lifetime
-                                * expires */
     int got_marker;            /* denotes end of successful request */
     int reply_hdr_state;
     int authenticated;         /* This ftp request is authenticated */
@@ -158,10 +155,6 @@ static int ftpStateFree(fd, ftpState)
        put_free_8k_page(ftpState->reply_hdr);
        ftpState->reply_hdr = NULL;
     }
-    if (ftpState->icp_page_ptr) {
-       put_free_8k_page(ftpState->icp_page_ptr);
-       ftpState->icp_page_ptr = NULL;
-    }
     requestUnlink(ftpState->request);
     xfree(ftpState);
     return 0;
@@ -343,10 +336,10 @@ int ftpReadReply(fd, data)
        return 0;
     }
     errno = 0;
-    IOStats.Ftp.reads++;
     len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
     debug(9, 5, "ftpReadReply: FD %d, Read %d bytes\n", fd, len);
     if (len > 0) {
+        IOStats.Ftp.reads++;
        for (clen = len - 1, bin = 0; clen; bin++)
            clen >>= 1;
        IOStats.Ftp.read_hist[bin]++;
@@ -444,8 +437,6 @@ void ftpSendComplete(fd, buf, size, errflag, data)
        put_free_8k_page(buf);  /* Allocated by ftpSendRequest. */
        buf = NULL;
     }
-    ftpState->icp_page_ptr = NULL;     /* So lifetime expire doesn't re-free */
-
     if (errflag) {
        squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
        comm_close(fd);
@@ -501,7 +492,6 @@ void ftpSendRequest(fd, data)
 
     buflen = strlen(data->request->urlpath) + 256;
     buf = (char *) get_free_8k_page();
-    data->icp_page_ptr = buf;
     memset(buf, '\0', buflen);
 
     path = data->request->urlpath;
@@ -557,7 +547,8 @@ void ftpSendRequest(fd, data)
        strlen(buf),
        30,
        ftpSendComplete,
-       (void *) data);
+       (void *) data,
+       put_free_8k_page);
 }
 
 void ftpConnInProgress(fd, data)
index e8308f8fdbb0f5cc1caa0681e86ebd185c20e606..faaaaa2c3e4381dd184be6bf084fdf34e7d9e575 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: gopher.cc,v 1.34 1996/07/19 17:38:37 wessels Exp $
+ * $Id: gopher.cc,v 1.35 1996/07/20 03:16:50 wessels Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -156,7 +156,6 @@ typedef struct gopher_ds {
     int cso_recno;
     int len;
     char *buf;                 /* pts to a 4k page */
-    char *icp_page_ptr;                /* Pts to gopherStart buffer that needs to be freed */
 } GopherData;
 
 GopherData *CreateGopherData();
@@ -669,8 +668,6 @@ int gopherReadReplyTimeout(fd, data)
     entry = data->entry;
     debug(10, 4, "GopherReadReplyTimeout: Timeout on %d\n url: %s\n", fd, entry->url);
     squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
-    if (data->icp_page_ptr)
-       put_free_4k_page(data->icp_page_ptr);
     comm_close(fd);
     return 0;
 }
@@ -684,8 +681,6 @@ void gopherLifetimeExpire(fd, data)
     entry = data->entry;
     debug(10, 4, "gopherLifeTimeExpire: FD %d: <URL:%s>\n", fd, entry->url);
     squid_error_entry(entry, ERR_LIFETIME_EXP, NULL);
-    if (data->icp_page_ptr)
-       put_free_4k_page(data->icp_page_ptr);
     comm_set_select_handler(fd,
        COMM_SELECT_READ | COMM_SELECT_WRITE,
        0,
@@ -899,7 +894,6 @@ void gopherSendComplete(fd, buf, size, errflag, data)
 
     if (buf)
        put_free_4k_page(buf);  /* Allocated by gopherSendRequest. */
-    gopherState->icp_page_ptr = NULL;
 }
 
 /* This will be called when connect completes. Write request. */
@@ -911,8 +905,6 @@ void gopherSendRequest(fd, data)
     LOCAL_ARRAY(char, query, MAX_URL);
     char *buf = get_free_4k_page();
 
-    data->icp_page_ptr = buf;
-
     if (data->type_id == GOPHER_CSO) {
        sscanf(data->request, "?%s", query);
        len = strlen(query) + 15;
@@ -935,7 +927,8 @@ void gopherSendRequest(fd, data)
        len,
        30,
        gopherSendComplete,
-       (void *) data);
+       (void *) data,
+       put_free_4k_page);
     if (BIT_TEST(data->entry->flag, CACHABLE))
        storeSetPublicKey(data->entry);         /* Make it public */
 }
index da70118f63136c7080daf3e325547af576f5e2ad..4ea4d8f5ba06b0c778c45db9a3ba30997b5d5d5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.63 1996/07/19 17:38:38 wessels Exp $
+ * $Id: http.cc,v 1.64 1996/07/20 03:16:51 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -139,12 +139,6 @@ static int httpStateFree(fd, httpState)
        put_free_8k_page(httpState->reply_hdr);
        httpState->reply_hdr = NULL;
     }
-    if (httpState->reqbuf && httpState->buf_type == BUF_TYPE_8K) {
-       put_free_8k_page(httpState->reqbuf);
-       httpState->reqbuf = NULL;
-    } else {
-       safe_free(httpState->reqbuf)
-    }
     requestUnlink(httpState->request);
     xfree(httpState);
     return 0;
@@ -445,11 +439,11 @@ static void httpReadReply(fd, httpState)
        return;
     }
     errno = 0;
-    IOStats.Http.reads++;
     len = read(fd, buf, SQUID_TCP_SO_RCVBUF);
     debug(11, 5, "httpReadReply: FD %d: len %d.\n", fd, len);
     comm_set_fd_lifetime(fd, 86400);   /* extend after good read */
     if (len > 0) {
+        IOStats.Http.reads++;
        for (clen = len - 1, bin = 0; clen; bin++)
            clen >>= 1;
        IOStats.Http.read_hist[bin]++;
@@ -529,13 +523,6 @@ static void httpSendComplete(fd, buf, size, errflag, data)
     debug(11, 5, "httpSendComplete: FD %d: size %d: errflag %d.\n",
        fd, size, errflag);
 
-    if (httpState->reqbuf && httpState->buf_type == BUF_TYPE_8K) {
-       put_free_8k_page(httpState->reqbuf);
-       httpState->reqbuf = NULL;
-    } else {
-       safe_free(httpState->reqbuf);
-    }
-
     if (errflag) {
        squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
        comm_close(fd);
@@ -572,6 +559,7 @@ static void httpSendRequest(fd, httpState)
     int cfd = -1;
     request_t *req = httpState->request;
     char *Method = RequestMethodStr[req->method];
+    int buftype = 0;
 
     debug(11, 5, "httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
     buflen = strlen(Method) + strlen(req->urlpath);
@@ -586,14 +574,13 @@ static void httpSendRequest(fd, httpState)
        }
     }
     if (buflen < DISK_PAGE_SIZE) {
-       httpState->reqbuf = get_free_8k_page();
-       memset(httpState->reqbuf, '\0', buflen);
-       httpState->buf_type = BUF_TYPE_8K;
+       buf = get_free_8k_page();
+       memset(buf, '\0', buflen);
+       buftype = BUF_TYPE_8K;
     } else {
-       httpState->reqbuf = xcalloc(buflen, 1);
-       httpState->buf_type = BUF_TYPE_MALLOC;
+       buf = xcalloc(buflen, 1);
+       buftype = BUF_TYPE_MALLOC;
     }
-    buf = httpState->reqbuf;
 
     sprintf(buf, "%s %s HTTP/1.0\r\n",
        Method,
@@ -647,7 +634,8 @@ static void httpSendRequest(fd, httpState)
        len,
        30,
        httpSendComplete,
-       httpState);
+       httpState,
+       buftype == BUF_TYPE_8K ? put_free_8k_page : xfree);
 }
 
 static void httpConnInProgress(fd, httpState)
index ec1c2bc1f1944b5c8d225e11d91bf2aa450f9590..14330c0ffae7c4208f3ccc86450bff4e48c66526 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ident.cc,v 1.5 1996/07/18 20:27:04 wessels Exp $
+ * $Id: ident.cc,v 1.6 1996/07/20 03:16:52 wessels Exp $
  *
  * DEBUG: section 31    Ident (RFC 931)
  * AUTHOR: Duane Wessels
@@ -83,7 +83,8 @@ void identStart(sock, icpState)
        strlen(reqbuf),
        5,                      /* timeout */
        identRequestComplete,
-       (void *) icpState);
+       (void *) icpState,
+       NULL);
     comm_set_select_handler(sock,
        COMM_SELECT_READ,
        (PF) identReadReply,
index d3fe3a828afe57cf699941dd3074895a8dcd9025..725a0e3721599accc103ffb5f24cc5459653acc4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ipcache.cc,v 1.34 1996/07/19 17:34:45 wessels Exp $
+ * $Id: ipcache.cc,v 1.35 1996/07/20 03:16:53 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -1014,7 +1014,8 @@ static void dnsDispatch(dns, i)
        strlen(buf),
        0,                      /* timeout */
        NULL,                   /* Handler */
-       NULL);                  /* Handler-data */
+       NULL,                   /* Handler-data */
+       xfree);
     debug(14, 5, "dnsDispatch: Request sent to DNS server #%d.\n",
        dns->id);
     dns->dispatch_time = current_time;
@@ -1289,7 +1290,8 @@ void ipcacheShutdownServers()
            strlen(shutdown),
            0,                  /* timeout */
            NULL,               /* Handler */
-           NULL);              /* Handler-data */
+           NULL,               /* Handler-data */
+           xfree);
        dnsData->flags |= DNS_FLAG_CLOSING;
     }
 }
index 7d9c45da1a7024b9af611a6389b9fdc078f33c64..4ec1be4d189f72b5fd2d7b01a594d4fe8f5e56a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: neighbors.cc,v 1.32 1996/07/19 17:35:23 wessels Exp $
+ * $Id: neighbors.cc,v 1.33 1996/07/20 03:16:53 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -182,6 +182,8 @@ void hierarchy_log_append(entry, code, timeout, cache_host)
        code = HIER_MAX;
     if (mem)
        mem->hierarchy_code = code;
+    if (mem && cache_host)
+       mem->hierarchy_host = xstrdup(cache_host);
 
     if (emulate_httpd_log) {
        if (squid_curtime != last_time) {
index 575d0e3c2e150ab6d7dfd3fc8a83623b7d549dcb..675df71b2f7266ad766941962f40b2de9ceeaca1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: redirect.cc,v 1.5 1996/07/18 20:27:07 wessels Exp $
+ * $Id: redirect.cc,v 1.6 1996/07/20 03:16:54 wessels Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -269,7 +269,8 @@ static void redirectDispatch(redirect, r)
        len,
        0,                      /* timeout */
        NULL,                   /* Handler */
-       NULL);                  /* Handler-data */
+       NULL,                   /* Handler-data */
+       xfree);
     debug(29, 5, "redirectDispatch: Request sent to Redirector #%d, %d bytes\n",
        redirect->index + 1, len);
     RedirectStats.use_hist[redirect->index]++;
index 5c2d367f54ab73417d06af740e1f55c57eacea26..553ae119941eab8795a53a8c876470d9d5b34f62 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.29 1996/07/19 17:38:38 wessels Exp $
+ * $Id: squid.h,v 1.30 1996/07/20 03:16:54 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -199,7 +199,7 @@ typedef unsigned long u_num32;
 #endif
 #define NUM32LEN sizeof(num32) /* this should always be 4 */
 
-#if MALLOC_GUARD
+#if PURIFY
 #define LOCAL_ARRAY(type,name,size) \
         static type *local_##name=NULL; \
         type *name = local_##name ? local_##name : \
index 5f1a50b493ed452a16d8d1834bac63d1e89dd401..02997171746f3f133c66de92ad945c8322dee58e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.6 1996/07/18 20:27:09 wessels Exp $
+ * $Id: ssl.cc,v 1.7 1996/07/20 03:16:55 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -339,7 +339,8 @@ static void sslConnInProgress(fd, sslState)
                strlen(buf),
                30,
                sslErrorComplete,
-               sslState);
+               sslState,
+               xfree);
            return;
        }
     }
@@ -369,7 +370,8 @@ static int sslConnect(fd, hp, sslState)
            strlen(buf),
            30,
            sslErrorComplete,
-           (void *) sslState);
+           (void *) sslState,
+               xfree);
        return COMM_ERROR;
     }
     debug(26, 5, "sslConnect: client=%d server=%d\n",
@@ -402,7 +404,8 @@ static int sslConnect(fd, hp, sslState)
                strlen(buf),
                30,
                sslErrorComplete,
-               (void *) sslState);
+               (void *) sslState,
+               xfree);
            return COMM_ERROR;
        } else {
            debug(26, 5, "sslConnect: conn %d EINPROGRESS\n", fd);
@@ -448,7 +451,8 @@ int sslStart(fd, url, request, mime_hdr, size_ptr)
            strlen(buf),
            30,
            sslErrorComplete,
-           (void *) sslState);
+           (void *) sslState,
+               xfree);
        return COMM_ERROR;
     }
     sslState = xcalloc(1, sizeof(SslStateData));
index 3f51d70f9d0589e7a6a00b06e94fbf29d78adb0b..92bdb5f5b70998c78169b0f7f44f0ed54f25874d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: stat.cc,v 1.42 1996/07/18 20:27:10 wessels Exp $
+ * $Id: stat.cc,v 1.43 1996/07/20 03:16:55 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -882,7 +882,7 @@ void parameter_get(obj, sentry)
 }
 
 
-void log_append(obj, url, id, size, action, method, http_code, msec, ident, hier)
+void log_append(obj, url, id, size, action, method, http_code, msec, ident, hier, neighbor)
      cacheinfo *obj;
      char *url;
      char *id;
@@ -893,10 +893,11 @@ void log_append(obj, url, id, size, action, method, http_code, msec, ident, hier
      int msec;
      char *ident;
      hier_code hier;
+     char *neighbor;
 {
     LOCAL_ARRAY(char, tmp, 6000);      /* MAX_URL is 4096 */
-    char *buf = NULL;
     int x;
+    static char *dash = "-";
 
     getCurrentTime();
 
@@ -917,11 +918,13 @@ void log_append(obj, url, id, size, action, method, http_code, msec, ident, hier
 #endif
 
     if (!method)
-       method = "-";
+       method = dash;
     if (!url)
-       url = "-";
+       url = dash;
     if (!ident || ident[0] == '\0')
-       ident = "-";
+       ident = dash;
+    if (!neighbor)
+       neighbor = dash;
 
     if (obj->logfile_status == LOG_ENABLE) {
        if (emulate_httpd_log)
@@ -934,29 +937,28 @@ void log_append(obj, url, id, size, action, method, http_code, msec, ident, hier
                action,
                size);
        else
-           sprintf(tmp, "%9d.%03d %6d %s %s/%03d/%s %d %s %s %s\n",
+           sprintf(tmp, "%9d.%03d %6d %s %s/%03d %d %s %s %s %s/%s\n",
                (int) current_time.tv_sec,
                (int) current_time.tv_usec / 1000,
                msec,
                id,
                action,
                http_code,
-               hier_strings[hier],
                size,
                method,
                url,
-               ident);
+               ident,
+               hier_strings[hier],
+               neighbor);
        x = file_write(obj->logfile_fd,
-           buf = xstrdup(tmp),
+           xstrdup(tmp),
            strlen(tmp),
            obj->logfile_access,
            NULL,
            NULL,
            xfree);
-       if (x != DISK_OK) {
+       if (x != DISK_OK)
            debug(18, 1, "log_append: File write failed.\n");
-           safe_free(buf);
-       }
     }
 }
 
index bf7f9e09b66eb54fc7dc0e2e3c22e5aaeda3a380..c57a505b0662efe84ab96074583a200f8819a6be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: stmem.cc,v 1.13 1996/07/17 17:03:45 wessels Exp $
+ * $Id: stmem.cc,v 1.14 1996/07/20 03:16:56 wessels Exp $
  *
  * DEBUG: section 19    Memory Primitives
  * AUTHOR: Harvest Derived
@@ -482,6 +482,13 @@ void stmemInit()
     mem_obj_pool.n_pages_in_use = 0;
     mem_obj_pool.max_pages = FD_SETSIZE >> 3;
 
+#if PURIFY
+    sm_stats.max_pages = 0;
+    disk_stats.max_pages = 0;
+    request_pool.max_pages = 0;
+    mem_obj_pool.max_pages = 0;
+#endif
+
     init_stack(&sm_stats.free_page_stack, sm_stats.max_pages);
     init_stack(&disk_stats.free_page_stack, disk_stats.max_pages);
     init_stack(&request_pool.free_page_stack, request_pool.max_pages);
index 919a408ee78dd8f9baae06ce71813c29c892707f..c64750130c9e123efc266054b33031405550e147 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: store.cc,v 1.72 1996/07/19 17:41:30 wessels Exp $
+ * $Id: store.cc,v 1.73 1996/07/20 03:16:57 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -260,6 +260,7 @@ static void destroy_MemObject(mem)
     safe_free(mem->mime_hdr);
     safe_free(mem->reply);
     safe_free(mem->e_abort_msg);
+    safe_free(mem->hierarchy_host);
     requestUnlink(mem->request);
     mem->request = NULL;
     put_free_mem_obj(mem);
@@ -1413,7 +1414,6 @@ static int storeDoRebuildFromDisk(data)
            &scan3,             /* last modified */
            &scan4,             /* size */
            url);               /* url */
-       debug(20, 9, "x = %d\n", x);
        if (x > 0)
            storeSwapFullPath(sfileno, swapfile);
        if (x != 6) {
index f6d04bb0d820fc1a2dc709d14c24d793eb581992..03eab98d16a1a93abbaf78fc9ad355fc41695295 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.6 1996/07/18 20:27:09 wessels Exp $
+ * $Id: tunnel.cc,v 1.7 1996/07/20 03:16:55 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -339,7 +339,8 @@ static void sslConnInProgress(fd, sslState)
                strlen(buf),
                30,
                sslErrorComplete,
-               sslState);
+               sslState,
+               xfree);
            return;
        }
     }
@@ -369,7 +370,8 @@ static int sslConnect(fd, hp, sslState)
            strlen(buf),
            30,
            sslErrorComplete,
-           (void *) sslState);
+           (void *) sslState,
+               xfree);
        return COMM_ERROR;
     }
     debug(26, 5, "sslConnect: client=%d server=%d\n",
@@ -402,7 +404,8 @@ static int sslConnect(fd, hp, sslState)
                strlen(buf),
                30,
                sslErrorComplete,
-               (void *) sslState);
+               (void *) sslState,
+               xfree);
            return COMM_ERROR;
        } else {
            debug(26, 5, "sslConnect: conn %d EINPROGRESS\n", fd);
@@ -448,7 +451,8 @@ int sslStart(fd, url, request, mime_hdr, size_ptr)
            strlen(buf),
            30,
            sslErrorComplete,
-           (void *) sslState);
+           (void *) sslState,
+               xfree);
        return COMM_ERROR;
     }
     sslState = xcalloc(1, sizeof(SslStateData));
index 7bf85b4b839c605bf1be571a4528a9c008a5e417..a83e71b60d8d1e6b3877fc8d079b49ba2cc9d2cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: wais.cc,v 1.33 1996/07/18 20:27:13 wessels Exp $
+ * $Id: wais.cc,v 1.34 1996/07/20 03:16:58 wessels Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -297,7 +297,6 @@ static void waisSendComplete(fd, buf, size, errflag, data)
            (void *) waisState,
            getReadTimeout());
     }
-    safe_free(buf);            /* Allocated by waisSendRequest. */
 }
 
 /* This will be called when connect completes. Write request. */
@@ -329,7 +328,8 @@ static void waisSendRequest(fd, waisState)
        len,
        30,
        waisSendComplete,
-       (void *) waisState);
+       (void *) waisState,
+       xfree);
     if (BIT_TEST(waisState->entry->flag, CACHABLE))
        storeSetPublicKey(waisState->entry);    /* Make it public */
 }