From: wessels <> Date: Thu, 11 Apr 1996 02:53:04 +0000 (+0000) Subject: add -U option for unlink on reload X-Git-Tag: SQUID_3_0_PRE1~6225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d68adf86573e3e2be525f6f11226687acb2fc045;p=thirdparty%2Fsquid.git add -U option for unlink on reload --- diff --git a/src/main.cc b/src/main.cc index 60554e8c0e..a66e65c018 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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); diff --git a/src/squid.h b/src/squid.h index 50e55ace1f..910acd8450 100644 --- a/src/squid.h +++ b/src/squid.h @@ -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 */ diff --git a/src/store.cc b/src/store.cc index 7eb043b194..bca19a26c1 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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: \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: : %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: \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);