-/* $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 */
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;
-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\
case 'R':
do_reuse = 0;
break;
+ case 'U':
+ opt_unlink_on_reload = 1;
+ break;
case 'f':
xfree(config_file);
config_file = xstrdup(optarg);
-/* $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
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;
}
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;
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 */
}
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;
}
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);