]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
add -U option for unlink on reload
authorwessels <>
Thu, 11 Apr 1996 02:53:04 +0000 (02:53 +0000)
committerwessels <>
Thu, 11 Apr 1996 02:53:04 +0000 (02:53 +0000)
src/main.cc
src/squid.h
src/store.cc

index 60554e8c0e1ad6d56c21527680d4b1efbefd1f1a..a66e65c018cf3a069db716538b3bed6ff7f890a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: main.cc,v 1.29 1996/04/10 20:45:30 wessels Exp $ */
+/* $Id: main.cc,v 1.30 1996/04/10 20:53:04 wessels Exp $ */
 
 /* DEBUG: Section 1             main: startup and main loop */
 
@@ -9,6 +9,7 @@ time_t next_cleaning = 0;
 int theAsciiConnection = -1;
 int theUdpConnection = -1;
 int do_reuse = 1;
+int opt_unlink_on_reload = 0;
 int catch_signals = 1;
 int do_dns_test = 1;
 char *config_file = NULL;
@@ -34,6 +35,7 @@ Usage: cached [-Rsehvz] [-f config-file] [-[apu] port]\n\
        -C        Do not catch fatal signals.\n\
        -D        Disable initial DNS tests.\n\
        -R        Do not set REUSEADDR on port.\n\
+       -U        Unlink expired objects on reload.\n\
        -f file   Use given config-file instead of\n\
                  $HARVEST_HOME/lib/cached.conf.\n\
        -a port  Specify ASCII port number (default: %d).\n\
@@ -74,6 +76,9 @@ static void mainParseOptions(argc, argv)
        case 'R':
            do_reuse = 0;
            break;
+       case 'U':
+           opt_unlink_on_reload = 1;
+           break;
        case 'f':
            xfree(config_file);
            config_file = xstrdup(optarg);
index 50e55ace1f52838791d0494bf0e4ff0030fbdb46..910acd8450239d15bc401f6f40b5545594c398cf 100644 (file)
@@ -1,5 +1,5 @@
 
-/* $Id: squid.h,v 1.12 1996/04/09 18:18:52 wessels Exp $ */
+/* $Id: squid.h,v 1.13 1996/04/10 20:53:34 wessels Exp $ */
 
 #include "config.h"
 #include "autoconf.h"
@@ -127,3 +127,4 @@ extern int theAsciiConnection;      /* main.c */
 extern int theUdpConnection;   /* main.c */
 extern int shutdown_pending;   /* main.c */
 extern int reread_pending;     /* main.c */
+extern int opt_unlink_on_reload;       /* main.c */
index 7eb043b1941af42fadf2633cb5df31249e7a7cb1..bca19a26c175020b507a0e54f9d99c88a8028abe 100644 (file)
@@ -1,6 +1,6 @@
 
-/* $Id: store.cc,v 1.40 1996/04/10 20:45:33 wessels Exp $ */
-#ident "$Id: store.cc,v 1.40 1996/04/10 20:45:33 wessels Exp $"
+/* $Id: store.cc,v 1.41 1996/04/10 20:53:05 wessels Exp $ */
+#ident "$Id: store.cc,v 1.41 1996/04/10 20:53:05 wessels Exp $"
 
 /*
  * DEBUG: Section 20          store
@@ -934,7 +934,7 @@ int storeAddSwapDisk(path)
     if (cache_dirs == NULL)
        cache_dirs = create_dynamic_array(5, 5);
     /* XXX note xstrdup here prob means we
-       can't use destroy_dynamic_array() */
+     * can't use destroy_dynamic_array() */
     insert_dynamic_array(cache_dirs, xstrdup(path));
     return ++ncache_dirs;
 }
@@ -1300,10 +1300,8 @@ void storeRebuildFromDisk()
        size = 0;
        if (sscanf(line_in, "%s %s %d %d %d",
                log_swapfile, url, &scan1, &scan2, &scan3) != 5) {
-#ifdef UNLINK_ON_RELOAD
-           if (log_swapfile[0])
+           if (opt_unlink_on_reload && log_swapfile[0])
                safeunlink(log_swapfile, 0);
-#endif
            continue;
        }
        expires = (time_t) scan1;
@@ -1324,22 +1322,19 @@ void storeRebuildFromDisk()
            if (stat(swapfile, &sb) < 0) {
                if (expires < cached_curtime) {
                    debug(20, 3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
-#ifdef UNLINK_ON_RELOAD
-                   safeunlink(swapfile, 1);
-#endif
+                   if (opt_unlink_on_relaod)
+                       safeunlink(swapfile, 1);
                    expcount++;
                } else {
                    debug(20, 3, "storeRebuildFromDisk: Swap file missing: <URL:%s>: %s: %s.\n", url, swapfile, xstrerror());
-#ifdef UNLINK_ON_RELOAD
-                   safeunlink(log_swapfile, 1);
-#endif
+                   if (opt_unlink_on_relaod)
+                       safeunlink(log_swapfile, 1);
                }
                continue;
            }
            if ((size = sb.st_size) == 0) {
-#ifdef UNLINK_ON_RELOAD
-               safeunlink(log_swapfile, 1);
-#endif
+               if (opt_unlink_on_relaod)
+                   safeunlink(log_swapfile, 1);
                continue;
            }
            /* timestamp might be a little bigger than sb.st_mtime */
@@ -1361,9 +1356,8 @@ void storeRebuildFromDisk()
        }
        if (expires < cached_curtime) {
            debug(20, 3, "storeRebuildFromDisk: Expired: <URL:%s>\n", url);
-#ifdef UNLINK_ON_RELOAD
-           safeunlink(swapfile, 1);
-#endif
+           if (opt_unlink_on_relaod)
+               safeunlink(swapfile, 1);
            expcount++;
            continue;
        }
@@ -2427,7 +2421,7 @@ int storeInit()
 
     storelog_fd = file_open("store.log", NULL, O_WRONLY | O_APPEND | O_CREAT);
 
-    for (w = getCacheDirs(); w; w=w->next)
+    for (w = getCacheDirs(); w; w = w->next)
        storeAddSwapDisk(w->key);
     storeSanityCheck();
     file_map_create(MAX_SWAP_FILE);