htcacheclean.c revision 6850c836b8c7c688ef8a8ec280e798e1d0bfbf01
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd/* Licensed to the Apache Software Foundation (ASF) under one or more
c1a9af42c178bed7efa0a6bb7f45f46ffb269719rbb * contributor license agreements. See the NOTICE file distributed with
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * this work for additional information regarding copyright ownership.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * The ASF licenses this file to You under the Apache License, Version 2.0
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * (the "License"); you may not use this file except in compliance with
c1a9af42c178bed7efa0a6bb7f45f46ffb269719rbb * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
c1a9af42c178bed7efa0a6bb7f45f46ffb269719rbb * limitations under the License.
c1a9af42c178bed7efa0a6bb7f45f46ffb269719rbb * htcacheclean.c: simple program for cleaning of
0af0bae91bd14e86a02d05fbd88105267ae4b244trawick * the disk cache of the Apache HTTP server
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb * Contributed by Andreas Steinmetz <ast domdv.de>
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb * 8 Oct 2004
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb/* define the following for debugging */
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb * Note: on Linux delays <= 2ms are busy waits without
9346b854b0827ae0645b456ffd2b4938f1e73c03gstein * scheduling, so never use a delay <= 2ms below
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb#define DELETE_NICE 10 /* be nice after this amount of delete ops */
9346b854b0827ae0645b456ffd2b4938f1e73c03gstein#define STAT_ATTEMPTS 10 /* maximum stat attempts for a file */
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb#define DIRINFO (APR_FINFO_MTIME|APR_FINFO_SIZE|APR_FINFO_TYPE|APR_FINFO_LINK)
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbbtypedef struct _direntry {
f6431843a765abbef9e79a26f4a5f077f0cef7dbrbb int type; /* type of file/fileset: TEMP, HEADER, DATA, HEADERDATA */
} DIRENTRY;
typedef struct _entry {
} ENTRY;
#ifdef DEBUG
#ifdef DEBUG
static int called = 0;
if (!called) {
return APR_ENOMEM;
if (!verbose) {
if (unsolicited) {
char *nextpath;
apr_pool_t *p;
if (dryrun) {
apr_pool_destroy(p);
if (benice) {
delcount = 0;
char *nextpath;
apr_pool_t *p;
if (dryrun) {
apr_pool_destroy(p);
if (benice) {
delcount = 0;
apr_pool_t *p;
apr_hash_t *h;
apr_hash_index_t *i;
DIRENTRY *d, *t, *n;
ENTRY *e;
h = apr_hash_make(p);
skip = 0;
if (interrupted) {
if (!base++) {
if (!ext) {
if (interrupted) {
void *hvalue;
d = hvalue;
switch(d->type) {
case HEADERDATA:
case HEADER:
case DATA:
case TEMP:
if (interrupted) {
apr_pool_destroy(p);
if (benice) {
if (interrupted) {
sum = 0;
entries = 0;
entries++;
entries--;
if (!interrupted) {
if (interrupted) {
entries--;
if (!interrupted) {
if (interrupted) {
oldest = e;
entries--;
if (!interrupted) {
if (error) {
option));
apr_getopt_t *o;
char opt;
const char *arg;
interrupted = 0;
repeat = 0;
isdaemon = 0;
dryrun = 0;
limit_found = 0;
max = 0;
verbose = 0;
realclean = 0;
benice = 0;
deldirs = 0;
intelligent = 0;
if (argc) {
switch (opt) {
if (intelligent) {
if (dryrun) {
if (benice) {
if (deldirs) {
if (verbose) {
if (realclean) {
if (isdaemon) {
if (limit_found) {
char *end;
if (proxypath) {
if (!proxypath) {
if (max <= 0) {
#ifndef DEBUG
if (isdaemon) {
delcount = 0;
unsolicited = 0;
dowork = 0;
switch (intelligent) {
if (isdaemon) {
delay = 0;