htcacheclean.c revision c42b94a839cae93073d33b0d21f0ff1118d958e8
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive/* Licensed to the Apache Software Foundation (ASF) under one or more
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * contributor license agreements. See the NOTICE file distributed with
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * this work for additional information regarding copyright ownership.
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * The ASF licenses this file to You under the Apache License, Version 2.0
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * (the "License"); you may not use this file except in compliance with
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * the License. You may obtain a copy of the License at
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Unless required by applicable law or agreed to in writing, software
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * distributed under the License is distributed on an "AS IS" BASIS,
2e545ce2450a9953665f701bb05350f0d3f26275nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * limitations under the License.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * htcacheclean.c: simple program for cleaning of
5a58787efeb02a1c3f06569d019ad81fd2efa06end * the disk cache of the Apache HTTP server
5a58787efeb02a1c3f06569d019ad81fd2efa06end * Contributed by Andreas Steinmetz <ast domdv.de>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * 8 Oct 2004
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive/* define the following for debugging */
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * Note: on Linux delays <= 2ms are busy waits without
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive * scheduling, so never use a delay <= 2ms below
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive#define DELETE_NICE 10 /* be nice after this amount of delete ops */
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive#define STAT_ATTEMPTS 10 /* maximum stat attempts for a file */
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodl#define DIRINFO (APR_FINFO_MTIME|APR_FINFO_SIZE|APR_FINFO_TYPE|APR_FINFO_LINK)
1f5c891e2da26b6b787e429aa71d9c899cc26dfcnoodltypedef struct _direntry {
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive int type; /* type of file/fileset: TEMP, HEADER, DATA, HEADERDATA */
59879db9d12c2ea10f77b2c44d6d3aba89bb9cb3slive apr_time_t htime; /* headers file modification time */
d474d8ef01ec5c2a09341cd148851ed383c3287crbowentypedef struct _entry {
205f749042ed530040a4f0080dbcb47ceae8a374rjung apr_time_t response_time; /* cache entry time of last response to client */
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen apr_time_t htime; /* headers file modification time */
#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;