--------------------- PatchSet 4155 Date: 2002/05/21 10:18:02 Author: serassio Branch: coss Tag: (none) Log: Added close of COSS store file at Squid shutdown, CossInfo allocation cleanup, log file pathname generation according to others store fs Members: src/fs/coss/store_coss.h:1.4.12.1->1.4.12.2 src/fs/coss/store_dir_coss.c:1.16.10.3->1.16.10.4 Index: squid/src/fs/coss/store_coss.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/coss/store_coss.h,v retrieving revision 1.4.12.1 retrieving revision 1.4.12.2 diff -u -r1.4.12.1 -r1.4.12.2 --- squid/src/fs/coss/store_coss.h 16 Oct 2001 00:51:36 -0000 1.4.12.1 +++ squid/src/fs/coss/store_coss.h 21 May 2002 10:18:02 -0000 1.4.12.2 @@ -20,6 +20,7 @@ #define COSS_ALLOC_ALLOCATE 1 #define COSS_ALLOC_REALLOC 2 +#define SWAPDIR_COSS "coss" typedef int64_t off64_t; typedef int64_t size64_t; Index: squid/src/fs/coss/store_dir_coss.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/coss/store_dir_coss.c,v retrieving revision 1.16.10.3 retrieving revision 1.16.10.4 diff -u -r1.16.10.3 -r1.16.10.4 --- squid/src/fs/coss/store_dir_coss.c 21 May 2002 09:10:51 -0000 1.16.10.3 +++ squid/src/fs/coss/store_dir_coss.c 21 May 2002 10:18:02 -0000 1.16.10.4 @@ -42,7 +42,7 @@ #define STORE_META_BUFSZ 4096 int n_coss_dirs = 0; -/* static int last_coss_pick_index = -1; */ +static int last_coss_pick_index = -1; int coss_initialised = 0; MemPool *coss_state_pool = NULL; MemPool *coss_index_pool = NULL; @@ -100,6 +100,7 @@ LOCAL_ARRAY(char, pathtmp, SQUID_MAXPATHLEN); LOCAL_ARRAY(char, digit, 32); char *pathtmp2; + int i; if (Config.Log.swap) { xstrncpy(pathtmp, sd->path, SQUID_MAXPATHLEN - 64); pathtmp2 = pathtmp; @@ -116,6 +117,12 @@ } } else { xstrncpy(path, sd->path, SQUID_MAXPATHLEN - 64); + for (i = strlen(path); i >= 0; i--) { + if (path[i] == '/') { + path[i] = '\0'; + break; + } + } strcat(path, "/swap.state"); } if (ext) @@ -678,6 +685,7 @@ file_close(cs->swaplog_fd); cs->swaplog_fd = -1; } + xfree(cs); n_coss_dirs--; } @@ -764,9 +772,9 @@ if (size <= 0) fatal("storeCossDirParse: invalid size value"); - cs = xmalloc(sizeof(CossInfo)); + cs = xcalloc(1, sizeof(CossInfo)); if (cs == NULL) - fatal("storeCossDirParse: couldn't xmalloc() CossInfo!\n"); + fatal("storeCossDirParse: couldn't xcalloc() CossInfo!\n"); sd->index = index; sd->path = xstrdup(path); @@ -851,7 +859,6 @@ dump_cachedir_options(entry, NULL, s); } -#if OLD_UNUSED_CODE SwapDir * storeCossDirPick(void) { @@ -862,7 +869,7 @@ return NULL; for (i = 0; i < Config.cacheSwap.n_configured; i++) { SD = &Config.cacheSwap.swapDirs[i]; - if (SD->type == SWAPDIR_COSS) { + if (strcmp(SD->type, SWAPDIR_COSS) == 0) { if ((last_coss_pick_index == -1) || (n_coss_dirs == 1)) { last_coss_pick_index = i; return SD; @@ -876,7 +883,7 @@ } for (i = 0; i < Config.cacheSwap.n_configured; i++) { SD = &Config.cacheSwap.swapDirs[i]; - if (SD->type == SWAPDIR_COSS) { + if (strcmp(SD->type, SWAPDIR_COSS) == 0) { if ((last_coss_pick_index == -1) || (n_coss_dirs == 1)) { last_coss_pick_index = i; return SD; @@ -890,7 +897,6 @@ } return NULL; } -#endif /* * initial setup/done code @@ -898,6 +904,10 @@ static void storeCossDirDone(void) { + int i; + + for (i=0; i < n_coss_dirs; i++) + storeCossDirShutdown(storeCossDirPick()); memPoolDestroy(&coss_state_pool); /* memPoolDestroy(&coss_index_pool); XXX Should be here? */ coss_initialised = 0;