- From: <neumann@nestroy.wi-inf.uni-essen.de>
- Date: Sat Dec 14 13:09:00 1996
- To: www-lib-bugs@w3.org
Hi there,
the following patch fixes a couple of things in HTCache.c:
- DUMP_FREQUENCY is set to 1 (was 10)
i guess that FEQUENCY of 10 was supposed to be a feature, but
unfortunately this leads to inconsitencies between the .index
file and the actually cached files.
- there were a few problems concerned reading of .index
(wrong variable was used, checking was not strict enough)
- several minor changes concerning TRACE output: i tried
modified several cache related trace guards from APP_TRACE
or CORE_TRACE to CACHE_TRACE, somewhere was a variable missing
needed for %-substituion, somewhere a possible null string was
handed to %s.
best regards
-gustaf neumann
==============================================================================
*** HTCache.c.ORIG Thu Nov 28 16:55:22 1996
--- HTCache.c Sat Dec 14 17:56:46 1996
***************
*** 29,35 ****
#define HT_CACHE_META ".meta"
#define HASH_SIZE 67
! #define DUMP_FREQUENCY 10 /* Dump index after 10 loads */
#define MEGA 0x100000L
#define CACHE_SIZE (20*MEGA) /* Default cache size is 20M */
--- 29,36 ----
#define HT_CACHE_META ".meta"
#define HASH_SIZE 67
! /*#define DUMP_FREQUENCY 10*/ /* Dump index after 10 loads */
! #define DUMP_FREQUENCY 1 /* Dump index after every load */
#define MEGA 0x100000L
#define CACHE_SIZE (20*MEGA) /* Default cache size is 20M */
***************
*** 239,257 ****
*/
PUBLIC BOOL HTCacheIndex_write (const char * cache_root)
{
if (cache_root && CacheTable) {
char * index = cache_index_name(cache_root);
FILE * fp = NULL;
! if (CACHE_TRACE) HTTrace("Cache Index. Writing index `%s\'\n", index);
/*
** Open the file for writing. Note - we don't take a backup!
** This should probably be fixed!
*/
- if (!index) return NO;
if ((fp = fopen(index, "wb")) == NULL) {
if (CACHE_TRACE)
! HTTrace("Cache Index. Can't open `%s\' for writing\n", index);
HT_FREE(index);
return NO;
}
--- 240,261 ----
*/
PUBLIC BOOL HTCacheIndex_write (const char * cache_root)
{
+ if (CACHE_TRACE) HTTrace("Cache....... Index write <%s>\n", cache_root);
+
if (cache_root && CacheTable) {
char * index = cache_index_name(cache_root);
FILE * fp = NULL;
!
! if (!index) return NO;
! if (CACHE_TRACE) HTTrace("Cache Index. writing index `%s\'\n", index);
/*
** Open the file for writing. Note - we don't take a backup!
** This should probably be fixed!
*/
if ((fp = fopen(index, "wb")) == NULL) {
if (CACHE_TRACE)
! HTTrace("Cache Index. can't open `%s\' for writing\n", index);
HT_FREE(index);
return NO;
}
***************
*** 280,286 ****
pres->corrected_initial_age,
pres->must_revalidate+0x30) < 0) {
if (CACHE_TRACE)
! HTTrace("Cache Index. Error writing cache index\n");
return NO;
}
}
--- 284,290 ----
pres->corrected_initial_age,
pres->must_revalidate+0x30) < 0) {
if (CACHE_TRACE)
! HTTrace("Cache Index. error writing cache index\n");
return NO;
}
}
***************
*** 320,333 ****
if (sscanf(line, "%ld %ld %c %d %d %ld %ld %ld %c",
&cache->expires,
&cache->size,
! &cache->range,
&cache->hash,
&cache->hits,
&cache->freshness_lifetime,
&cache->response_time,
&cache->corrected_initial_age,
! &validate) < 0) {
! if (CACHE_TRACE) HTTrace("Cache Index. Error reading cache index\n");
return NO;
}
cache->range = range-0x30;
--- 324,337 ----
if (sscanf(line, "%ld %ld %c %d %d %ld %ld %ld %c",
&cache->expires,
&cache->size,
! &range,
&cache->hash,
&cache->hits,
&cache->freshness_lifetime,
&cache->response_time,
&cache->corrected_initial_age,
! &validate) < 9) {
! if (CACHE_TRACE) HTTrace("Cache Index. invalid cache entry: '%s'\n", line);
return NO;
}
cache->range = range-0x30;
***************
*** 362,369 ****
HTTotalSize += cache->size;
return YES;
}
- return NO;
}
/*
--- 366,374 ----
HTTotalSize += cache->size;
return YES;
+ } else {
+ return NO;
}
}
/*
***************
*** 437,443 ****
{
if (me) {
int status = HTCacheIndex_flush(me);
! if (APP_TRACE) HTTrace("Cache Index. FREEING....\n");
HTChunk_delete(me->buffer);
HT_FREE(me);
return status;
--- 442,448 ----
{
if (me) {
int status = HTCacheIndex_flush(me);
! if (CACHE_TRACE) HTTrace("Cache Index. FREEING\n");
HTChunk_delete(me->buffer);
HT_FREE(me);
return status;
***************
*** 449,455 ****
{
if (me) {
int status = HT_ERROR;
! if (APP_TRACE) HTTrace("Cache Index. ABORTING...\n");
HTChunk_delete(me->buffer);
HT_FREE(me);
return status;
--- 454,460 ----
{
if (me) {
int status = HT_ERROR;
! if (CACHE_TRACE) HTTrace("Cache Index. ABORTING\n");
HTChunk_delete(me->buffer);
HT_FREE(me);
return status;
***************
*** 507,512 ****
--- 512,518 ----
HT_FREE(file);
HT_FREE(index);
}
+ if (CACHE_TRACE) HTTrace("Cache Index. read returns %d\n", status);
return status;
}
***************
*** 832,838 ****
int hash = 0;
char * url = NULL;
if (!request || !response || !anchor) {
! if (CORE_TRACE) HTTrace("Cache....... Bad argument\n");
return NULL;
}
--- 838,844 ----
int hash = 0;
char * url = NULL;
if (!request || !response || !anchor) {
! if (CACHE_TRACE) HTTrace("Cache....... Bad argument\n");
return NULL;
}
***************
*** 869,879 ****
HTCache_findName(pres);
HTList_addObject(list, (void *) pres);
new_entries++;
! } else
HT_FREE(url);
if (HTCache_hasLock(pres)) {
! if (CACHE_TRACE) HTTrace("Cache....... Entry %p locked\n");
return pres;
}
--- 875,886 ----
HTCache_findName(pres);
HTList_addObject(list, (void *) pres);
new_entries++;
! } else {
HT_FREE(url);
+ }
if (HTCache_hasLock(pres)) {
! if (CACHE_TRACE) HTTrace("Cache....... Entry %p locked\n", pres);
return pres;
}
***************
*** 939,944 ****
--- 946,953 ----
return NULL;
}
list = CacheTable[hash];
+
+ if (CACHE_TRACE) HTTrace("Cache....... search for entry %s\n", url);
/* Search the cache */
{
==============================================================================
--
Wirtschaftsinformatik und Softwaretechnik
Universitaet GH Essen, FB5
Altendorfer Strasse 97-101, Eingang B, D-45143 Essen
Tel.: +49 (0201) 81003-74, Fax: +49 (0201) 81003-73
Gustaf.Neumann@uni-essen.de
http://mohegan.wi-inf.uni-essen.de/Neumann.html
Received on Saturday, 14 December 1996 13:09:00 UTC