Lines 287-292
Link Here
|
287 |
int skip, retries; |
287 |
int skip, retries; |
288 |
disk_cache_info_t disk_info; |
288 |
disk_cache_info_t disk_info; |
289 |
|
289 |
|
|
|
290 |
|
290 |
APR_RING_INIT(&anchor, _direntry, link); |
291 |
APR_RING_INIT(&anchor, _direntry, link); |
291 |
apr_pool_create(&p, pool); |
292 |
apr_pool_create(&p, pool); |
292 |
h = apr_hash_make(p); |
293 |
h = apr_hash_make(p); |
Lines 379-384
Link Here
|
379 |
continue; |
380 |
continue; |
380 |
} |
381 |
} |
381 |
|
382 |
|
|
|
383 |
if(strncasecmp(base + strlen(base) - sizeof(CACHE_HEADER_SUFFIX) + 1, CACHE_HEADER_SUFFIX, sizeof(CACHE_HEADER_SUFFIX))) { |
384 |
continue; |
385 |
} |
386 |
|
387 |
|
382 |
if (!strncasecmp(base, AP_TEMPFILE_BASE, AP_TEMPFILE_BASELEN) |
388 |
if (!strncasecmp(base, AP_TEMPFILE_BASE, AP_TEMPFILE_BASELEN) |
383 |
&& strlen(base) == AP_TEMPFILE_NAMELEN) { |
389 |
&& strlen(base) == AP_TEMPFILE_NAMELEN) { |
384 |
d->basename += skip; |
390 |
d->basename += skip; |
Lines 421-430
Link Here
|
421 |
len = sizeof(format); |
427 |
len = sizeof(format); |
422 |
if (apr_file_read_full(fd, &format, len, |
428 |
if (apr_file_read_full(fd, &format, len, |
423 |
&len) == APR_SUCCESS) { |
429 |
&len) == APR_SUCCESS) { |
424 |
if (format == DISK_FORMAT_VERSION) { |
430 |
if (format == DISK_FORMAT_VERSION) { |
425 |
apr_off_t offset = 0; |
431 |
apr_off_t offset; |
426 |
|
|
|
427 |
apr_file_seek(fd, APR_SET, &offset); |
428 |
|
432 |
|
429 |
len = sizeof(disk_cache_info_t); |
433 |
len = sizeof(disk_cache_info_t); |
430 |
|
434 |
|
Lines 432-453
Link Here
|
432 |
&len) == APR_SUCCESS) { |
436 |
&len) == APR_SUCCESS) { |
433 |
e = apr_palloc(pool, sizeof(ENTRY)); |
437 |
e = apr_palloc(pool, sizeof(ENTRY)); |
434 |
APR_RING_INSERT_TAIL(&root, e, _entry, link); |
438 |
APR_RING_INSERT_TAIL(&root, e, _entry, link); |
435 |
e->expire = disk_info.expire; |
439 |
e->expire = disk_info.expire; |
436 |
e->response_time = disk_info.response_time; |
440 |
e->response_time = disk_info.response_time; |
437 |
e->htime = d->htime; |
441 |
// e->htime = d->htime; |
438 |
e->hsize = d->hsize; |
442 |
//e->hsize = d->hsize; |
|
|
443 |
e->htime = disk_info.date; |
444 |
e->hsize = disk_info.file_size; |
439 |
e->basename = apr_pstrdup(pool, d->basename); |
445 |
e->basename = apr_pstrdup(pool, d->basename); |
440 |
e->name = apr_palloc(pool, disk_info.name_len+1); |
446 |
e->name = apr_palloc(pool, disk_info.bodyname_len+1); |
|
|
447 |
offset = disk_info.name_len; |
448 |
apr_file_seek(fd, APR_CUR, &offset); |
441 |
if(apr_file_read_full(fd, e->name, |
449 |
if(apr_file_read_full(fd, e->name, |
442 |
disk_info.name_len, NULL) |
450 |
disk_info.bodyname_len, NULL) |
443 |
== APR_SUCCESS) |
451 |
== APR_SUCCESS) |
444 |
{ |
452 |
{ |
445 |
e->name[disk_info.name_len] = '\0'; |
453 |
e->name[disk_info.bodyname_len] = '\0'; |
446 |
} |
454 |
} |
447 |
else { |
455 |
else { |
448 |
e->name = "UNKNOWN"; |
456 |
e->name = "UNKNOWN"; |
449 |
} |
457 |
} |
450 |
apr_file_close(fd); |
458 |
// apr_file_printf(errfile, "e-basename: %s e->name: %s, name_len: %d, body: %d, file: %d" |
|
|
459 |
// APR_EOL_STR, e->basename, e->name, disk_info.name_len, disk_info.bodyname_len, disk_info.filename_len ); |
460 |
apr_file_close(fd); |
451 |
|
461 |
|
452 |
break; |
462 |
break; |
453 |
} |
463 |
} |
Lines 480-486
Link Here
|
480 |
current = apr_time_now(); |
490 |
current = apr_time_now(); |
481 |
if (realclean || d->htime < current - deviation |
491 |
if (realclean || d->htime < current - deviation |
482 |
|| d->htime > current + deviation) { |
492 |
|| d->htime > current + deviation) { |
483 |
delete_entry(path, d->basename, p); |
493 |
apr_file_printf(errfile, "header time %lld, current time %lld, deviation time %lld" |
|
|
494 |
APR_EOL_STR, d->htime, current, deviation ); |
495 |
delete_entry(path, d->basename, p); |
484 |
unsolicited += d->hsize; |
496 |
unsolicited += d->hsize; |
485 |
} |
497 |
} |
486 |
break; |
498 |
break; |
Lines 520-525
Link Here
|
520 |
apr_off_t sum, total, entries, etotal; |
532 |
apr_off_t sum, total, entries, etotal; |
521 |
ENTRY *e, *n, *oldest; |
533 |
ENTRY *e, *n, *oldest; |
522 |
|
534 |
|
|
|
535 |
|
523 |
sum = 0; |
536 |
sum = 0; |
524 |
entries = 0; |
537 |
entries = 0; |
525 |
|
538 |
|
Lines 547-552
Link Here
|
547 |
n = APR_RING_NEXT(e, link); |
560 |
n = APR_RING_NEXT(e, link); |
548 |
if (e->response_time > now || e->htime > now ) { |
561 |
if (e->response_time > now || e->htime > now ) { |
549 |
delete_entry(path, e->basename, pool); |
562 |
delete_entry(path, e->basename, pool); |
|
|
563 |
delete_entry(path, e->name, pool); |
550 |
sum -= e->hsize; |
564 |
sum -= e->hsize; |
551 |
entries--; |
565 |
entries--; |
552 |
APR_RING_REMOVE(e, link); |
566 |
APR_RING_REMOVE(e, link); |
Lines 570-576
Link Here
|
570 |
n = APR_RING_NEXT(e, link); |
584 |
n = APR_RING_NEXT(e, link); |
571 |
if (e->expire != APR_DATE_BAD && e->expire < now) { |
585 |
if (e->expire != APR_DATE_BAD && e->expire < now) { |
572 |
delete_entry(path, e->basename, pool); |
586 |
delete_entry(path, e->basename, pool); |
573 |
if(verbose > 1) { |
587 |
delete_entry(path, e->name, pool); |
|
|
588 |
if(verbose >= 1) { |
574 |
apr_file_printf(errfile, "Expired: %s\n", e->name); |
589 |
apr_file_printf(errfile, "Expired: %s\n", e->name); |
575 |
} |
590 |
} |
576 |
sum -= e->hsize; |
591 |
sum -= e->hsize; |
Lines 607-613
Link Here
|
607 |
} |
622 |
} |
608 |
|
623 |
|
609 |
delete_entry(path, oldest->basename, pool); |
624 |
delete_entry(path, oldest->basename, pool); |
610 |
if(verbose > 1) { |
625 |
delete_entry(path, oldest->name, pool); |
|
|
626 |
if(verbose >= 1) { |
611 |
apr_file_printf(errfile, "Old: (%d s) " |
627 |
apr_file_printf(errfile, "Old: (%d s) " |
612 |
"(%" APR_OFF_T_FMT " b) %s\n", |
628 |
"(%" APR_OFF_T_FMT " b) %s\n", |
613 |
(int) apr_time_sec(apr_time_now() - oldest->htime), |
629 |
(int) apr_time_sec(apr_time_now() - oldest->htime), |
Lines 912-918
Link Here
|
912 |
break; |
928 |
break; |
913 |
} |
929 |
} |
914 |
|
930 |
|
915 |
if (dowork && !interrupted) { |
931 |
if (dowork && !interrupted) { |
916 |
if (!process_dir(path, instance) && !interrupted) { |
932 |
if (!process_dir(path, instance) && !interrupted) { |
917 |
purge(path, instance, max); |
933 |
purge(path, instance, max); |
918 |
} |
934 |
} |