]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Added *FreeMemory() routines.
authorwessels <>
Fri, 27 Sep 1996 01:19:11 +0000 (01:19 +0000)
committerwessels <>
Fri, 27 Sep 1996 01:19:11 +0000 (01:19 +0000)
- Changed max_hov_vm_obj_size to 256k

src/cache_cf.cc
src/comm.cc
src/disk.cc
src/dns.cc
src/errorpage.cc
src/filemap.cc
src/redirect.cc
src/stmem.cc
src/store.cc
src/tools.cc

index 4997e307e384310522002a10fb0d4bb68440be4e..7d130857170b6e760c0a91e43c2b9622da463c74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.99 1996/09/24 18:50:05 wessels Exp $
+ * $Id: cache_cf.cc,v 1.100 1996/09/26 19:19:11 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -196,7 +196,7 @@ struct SquidConfig Config;
 #define DefaultIpcacheSize     1024
 #define DefaultIpcacheLow      90
 #define DefaultIpcacheHigh     95
-#define DefaultMaxHotvmObjSize (12<<10)        /* 12k */
+#define DefaultMaxHotvmObjSize (256<<10)       /* 256k */
 
 int httpd_accel_mode = 0;      /* for fast access */
 char *DefaultSwapDir = DEFAULT_SWAP_DIR;
@@ -206,6 +206,7 @@ char *cfg_filename = NULL;  /* just the last part */
 char ForwardedBy[256];
 
 char w_space[] = " \t\n";
+char null_string[] = "";
 char config_input_line[BUFSIZ];
 int config_lineno = 0;
 
@@ -215,7 +216,6 @@ static void parseIntegerValue _PARAMS((int *));
 static char fatal_str[BUFSIZ];
 
 static void configDoConfigure _PARAMS((void));
-static void configFreeMemory _PARAMS((void));
 static void configSetFactoryDefaults _PARAMS((void));
 static void parseAccessLogLine _PARAMS((void));
 static void parseAddressLine _PARAMS((struct in_addr *));
@@ -760,7 +760,7 @@ static void
 parseFtpOptionsLine(void)
 {
     char *token;
-    token = strtok(NULL, "");  /* Note "", don't separate these */
+    token = strtok(NULL, null_string);
     if (token == NULL)
        self_destruct();
     safe_free(Config.Program.ftpget_opts);
@@ -931,7 +931,7 @@ static void
 parseDebugOptionsLine(void)
 {
     char *token;
-    token = strtok(NULL, "");  /* Note "", don't separate these */
+    token = strtok(NULL, null_string);
     safe_free(Config.debugOptions);
     if (token == NULL) {
        Config.debugOptions = NULL;
@@ -1034,7 +1034,7 @@ static void
 parseErrHtmlLine(void)
 {
     char *token;
-    if ((token = strtok(NULL, "")))
+    if ((token = strtok(NULL, null_string)))
        Config.errHtmlText = xstrdup(token);
 }
 
@@ -1410,7 +1410,7 @@ safe_xstrdup(char *p)
     return p ? xstrdup(p) : p;
 }
 
-static void
+void
 configFreeMemory(void)
 {
     safe_free(Config.Wais.relayHost);
@@ -1549,6 +1549,6 @@ configDoConfigure(void)
     sprintf(ForwardedBy, "Forwarded: by http://%s:%d/",
        getMyHostname(), Config.Port.http);
     if (Config.errHtmlText == NULL)
-       Config.errHtmlText = xstrdup("");
+       Config.errHtmlText = xstrdup(null_string);
     storeConfigure();
 }
index 3001bec12c4fa58219d1ae0b166e4a9a054f02d1..cf8a2783ae762c5fa561d41b4960c1ab627646f9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.79 1996/09/24 20:17:28 wessels Exp $
+ * $Id: comm.cc,v 1.80 1996/09/26 19:19:12 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -1356,3 +1356,9 @@ comm_write(int fd, char *buf, int size, int timeout, rw_complete_handler * handl
        (PF) commHandleWrite,
        fd_table[fd].rwstate);
 }
+
+void
+commFreeMemory(void)
+{
+       safe_free(fd_table);
+}
index c2b2659e8ffdab848ce1d66806fc17e7235e2d56..fc7ee2ca63a28386d899c326443cb7bc048bf12d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: disk.cc,v 1.28 1996/09/20 06:28:35 wessels Exp $
+ * $Id: disk.cc,v 1.29 1996/09/26 19:19:13 wessels Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -586,3 +586,9 @@ diskWriteIsComplete(int fd)
 {
     return file_table[fd].write_q ? 0 : 1;
 }
+
+void
+diskFreeMemory(void)
+{
+       safe_free(file_table);
+}
index e2754170b10d9d1320f185c4181e6504612abe55..c0cc958a5084f485c93842aaad84e25508d4d87c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dns.cc,v 1.15 1996/09/24 20:17:28 wessels Exp $
+ * $Id: dns.cc,v 1.16 1996/09/26 19:19:14 wessels Exp $
  *
  * DEBUG: section 34    Dnsserver interface
  * AUTHOR: Harvest Derived
@@ -217,14 +217,9 @@ dnsGetFirstAvailable(void)
 
 
 void
-dnsOpenServers(void)
+dnsFreeMemory(void)
 {
-    int N = Config.dnsChildren;
-    char *prg = Config.Program.dnsserver;
     int k;
-    int dnssocket;
-    LOCAL_ARRAY(char, fd_note_buf, FD_ASCII_NOTE_SZ);
-
     /* free old structures if present */
     if (dns_child_table) {
        for (k = 0; k < NDnsServersAlloc; k++) {
@@ -233,6 +228,18 @@ dnsOpenServers(void)
        }
        safe_free(dns_child_table);
     }
+}
+
+void
+dnsOpenServers(void)
+{
+    int N = Config.dnsChildren;
+    char *prg = Config.Program.dnsserver;
+    int k;
+    int dnssocket;
+    LOCAL_ARRAY(char, fd_note_buf, FD_ASCII_NOTE_SZ);
+
+    dnsFreeMemory();
     dns_child_table = xcalloc(N, sizeof(dnsserver_t *));
     debug(34, 1, "dnsOpenServers: Starting %d 'dns_server' processes\n", N);
     NDnsServersAlloc = 0;
index 3ed83194df0b2a2d03711bbca71e0f6fe1a310da..4e7ab92290604b275a18df175b59d834f80fcace 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.41 1996/09/20 06:28:37 wessels Exp $
+ * $Id: errorpage.cc,v 1.42 1996/09/26 19:19:15 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -410,3 +410,11 @@ proxy_denied_msg(int code, int method, char *url, char *client)
        getMyHostname());
     return tmp_error_buf;
 }
+
+void
+errorpageFreeMemory(void)
+{
+       safe_free(tmp_error_buf);
+       safe_free(tbuf);
+       safe_free(auth_msg);
+}
index 96cd8e7c2e578eadf7aa96aa0872f2c89db3a58b..ad6c8225968ea5f4c3a9b5bf1cdcee6e59b4d02a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filemap.cc,v 1.11 1996/09/20 06:28:41 wessels Exp $
+ * $Id: filemap.cc,v 1.12 1996/09/26 19:19:17 wessels Exp $
  *
  * DEBUG: section 8     Swap File Bitmap
  * AUTHOR: Harvest Derived
@@ -215,6 +215,13 @@ file_map_allocate(int suggestion)
     return (0);                        /* NOTREACHED */
 }
 
+void
+filemapFreeMemory(void)
+{
+        safe_free(fm->file_map);
+       safe_free(fm);
+}
+
 #ifdef TEST
 
 #define TEST_SIZE 1<<16
index 7be0585c69088fac3367e06cd7dbb7b48213e7bb..48fca30ed53b123dc46671f29e18eb8b856f48ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: redirect.cc,v 1.19 1996/09/20 06:29:05 wessels Exp $
+ * $Id: redirect.cc,v 1.20 1996/09/26 19:19:20 wessels Exp $
  *
  * DEBUG: section 29    Redirector
  * AUTHOR: Duane Wessels
@@ -336,6 +336,20 @@ redirectStart(int cfd, icpStateData * icpState, RH handler, void *data)
        Enqueue(r);
 }
 
+void
+redirectFreeMemory(void)
+{
+    int k;
+    /* free old structures if present */
+    if (redirect_child_table) {
+       for (k = 0; k < NRedirectors; k++) {
+           put_free_4k_page(redirect_child_table[k]->inbuf);
+           safe_free(redirect_child_table[k]);
+       }
+       safe_free(redirect_child_table);
+    }
+}
+
 void
 redirectOpenServers(void)
 {
@@ -345,14 +359,9 @@ redirectOpenServers(void)
     LOCAL_ARRAY(char, fd_note_buf, FD_ASCII_NOTE_SZ);
     static int first_time = 0;
 
+    redirectFreeMemory();
     if (Config.Program.redirect == NULL)
        return;
-    /* free old structures if present */
-    if (redirect_child_table) {
-       for (k = 0; k < NRedirectors; k++)
-           safe_free(redirect_child_table[k]);
-       safe_free(redirect_child_table);
-    }
     NRedirectors = NRedirectorsOpen = Config.redirectChildren;
     redirect_child_table = xcalloc(NRedirectors, sizeof(redirector_t *));
     debug(29, 1, "redirectOpenServers: Starting %d '%s' processes\n",
index d04cd8f655c9f7050913854f29cd4975622f83f1..7a1f4b6e87b23db7ab44536f2916eb602bfa80d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: stmem.cc,v 1.26 1996/09/20 06:29:11 wessels Exp $
+ * $Id: stmem.cc,v 1.27 1996/09/26 19:19:21 wessels Exp $
  *
  * DEBUG: section 19    Memory Primitives
  * AUTHOR: Harvest Derived
@@ -118,6 +118,7 @@ stmem_stats mem_obj_pool;
 
 static void *get_free_thing _PARAMS((stmem_stats * thing));
 static void put_free_thing _PARAMS((stmem_stats * thing, void *p));
+static void stmemFreeThingMemory _PARAMS((stmem_stats * thing));
 
 
 void
@@ -441,3 +442,22 @@ stmemInit(void)
     init_stack(&request_pool.free_page_stack, request_pool.max_pages);
     init_stack(&mem_obj_pool.free_page_stack, mem_obj_pool.max_pages);
 }
+
+static void
+stmemFreeThingMemory(stmem_stats * thing)
+{
+    void *p;
+    while (!empty_stack(&thing->free_page_stack)) {
+       p = pop(&thing->free_page_stack);
+       safe_free(p);
+    }
+}
+
+void
+stmemFreeMemory(void)
+{
+    stmemFreeThingMemory(&sm_stats);
+    stmemFreeThingMemory(&disk_stats);
+    stmemFreeThingMemory(&request_pool);
+    stmemFreeThingMemory(&mem_obj_pool);
+}
index 05c26aa2441c77c2383eb1ce51dc68c0b2d8ee51..1f3bbffb1dc0d2d1826e623a99f73e63b3e3b2c3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.120 1996/09/20 23:27:00 wessels Exp $
+ * $Id: store.cc,v 1.121 1996/09/26 19:19:23 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -2656,6 +2656,10 @@ storeWriteCleanLog(void)
            continue;
        if (e->object_len <= 0)
            continue;
+        if (BIT_TEST(e->flag, RELEASE_REQUEST))
+           continue;
+       if (BIT_TEST(e->flag, KEY_PRIVATE))
+           continue;
        storeSwapFullPath(e->swap_file_number, swapfilename);
        x = fprintf(fp, "%08x %08x %08x %08x %9d %s\n",
            (int) e->swap_file_number,
@@ -2838,3 +2842,16 @@ storeNegativeCache(StoreEntry * e)
     e->expires = squid_curtime + Config.negativeTtl;
     BIT_SET(e->flag, ENTRY_NEGCACHED);
 }
+
+void
+storeFreeMemory(void)
+{
+    StoreEntry *e;
+#ifdef THIS_IS_SLOW
+    while ((e = (StoreEntry *) storeFindFirst(store_table))) {
+       storeHashDelete(e);
+       destroy_StoreEntry(e);
+    }
+#endif
+    hashFreeMemory(store_table);
+}
index 9454bb42ad05b525f0b45d5d7bd50360f24b0cad..8e58b43a4bb76bf9ecf3c391119ad04367cf01c1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.65 1996/09/24 20:16:42 wessels Exp $
+ * $Id: tools.cc,v 1.66 1996/09/26 19:19:24 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -292,11 +292,21 @@ normal_shutdown(void)
     }
     storeWriteCleanLog();
     PrintRusage(NULL, debug_log);
-    debug(21, 0, "Squid Cache (Version %s): Exiting normally.\n",
-       version_string);
     storeCloseLog();
     statCloseLog();
     fclose(debug_log);
+    configFreeMemory();
+    diskFreeMemory();
+    storeFreeMemory();
+    commFreeMemory();
+    filemapFreeMemory();
+    dnsFreeMemory();
+    redirectFreeMemory();
+    fdstatFreeMemory();
+    errorpageFreeMemory();
+    stmemFreeMemory();
+    debug(21, 0, "Squid Cache (Version %s): Exiting normally.\n",
+       version_string);
     exit(0);
 }