--------------------- PatchSet 342 Date: 2002/12/13 08:22:57 Author: rbcollins Branch: unify-io Tag: (none) Log: make init a method Members: src/SwapDir.h:1.1.2.7->1.1.2.8 src/store_dir.cc:1.4.10.2->1.4.10.3 src/ufscommon.cc:1.4.10.6->1.4.10.7 src/ufscommon.h:1.1.20.29->1.1.20.30 src/fs/aufs/store_asyncufs.h:1.2.12.33->1.2.12.34 src/fs/aufs/store_dir_aufs.cc:1.2.12.9->1.2.12.10 src/fs/coss/store_coss.h:1.3.10.9->1.3.10.10 src/fs/coss/store_dir_coss.cc:1.4.10.6->1.4.10.7 src/fs/diskd/store_dir_diskd.cc:1.2.16.16->1.2.16.17 src/fs/diskd/store_diskd.h:1.1.20.33->1.1.20.34 src/fs/null/store_null.cc:1.1.20.5->1.1.20.6 src/fs/ufs/store_dir_ufs.cc:1.1.20.7->1.1.20.8 src/fs/ufs/store_ufs.h:1.1.20.24->1.1.20.25 Index: squid3/src/SwapDir.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SwapDir.h,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid3/src/SwapDir.h 11 Dec 2002 21:45:22 -0000 1.1.2.7 +++ squid3/src/SwapDir.h 13 Dec 2002 08:22:57 -0000 1.1.2.8 @@ -1,6 +1,6 @@ /* - * $Id: SwapDir.h,v 1.1.2.7 2002/12/11 21:45:22 rbcollins Exp $ + * $Id: SwapDir.h,v 1.1.2.8 2002/12/13 08:22:57 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,7 +34,6 @@ #ifndef SQUID_SWAPDIR_H #define SQUID_SWAPDIR_H -typedef void STINIT(SwapDir *); typedef void STNEWFS(SwapDir *); typedef void STDUMP(StoreEntry *, SwapDir *); typedef void STFREE(SwapDir *); @@ -62,7 +61,7 @@ SwapDir() : IO(NULL), max_objsize (-1){ fs.blksize = 1024; } - ~SwapDir(); + virtual ~SwapDir(); const char *type; IOStrategy *IO; int cur_size; @@ -78,7 +77,7 @@ unsigned int selected:1; unsigned int read_only:1; } flags; - STINIT *init; /* Initialise the fs */ + virtual void init() = 0; /* Initialise the fs */ STNEWFS *newfs; /* Create a new fs */ STDUMP *dump; /* Dump fs config snippet */ STFREE *freefs; /* Free the fs data */ Index: squid3/src/store_dir.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store_dir.cc,v retrieving revision 1.4.10.2 retrieving revision 1.4.10.3 diff -u -r1.4.10.2 -r1.4.10.3 --- squid3/src/store_dir.cc 2 Dec 2002 15:25:38 -0000 1.4.10.2 +++ squid3/src/store_dir.cc 13 Dec 2002 08:22:57 -0000 1.4.10.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.4.10.2 2002/12/02 15:25:38 rbcollins Exp $ + * $Id: store_dir.cc,v 1.4.10.3 2002/12/13 08:22:57 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -61,11 +61,8 @@ storeDirInit(void) { int i; - SwapDir *sd; - for (i = 0; i < Config.cacheSwap.n_configured; i++) { - sd = INDEXSD(i); - sd->init(sd); - } + for (i = 0; i < Config.cacheSwap.n_configured; i++) + INDEXSD(i)->init(); if (0 == strcasecmp(Config.store_dir_select_algorithm, "round-robin")) { storeDirSelectSwapDir = storeDirSelectSwapDirRoundRobin; debug(47, 1) ("Using Round Robin store dir selection\n"); Index: squid3/src/ufscommon.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.cc,v retrieving revision 1.4.10.6 retrieving revision 1.4.10.7 diff -u -r1.4.10.6 -r1.4.10.7 --- squid3/src/ufscommon.cc 6 Dec 2002 23:43:03 -0000 1.4.10.6 +++ squid3/src/ufscommon.cc 13 Dec 2002 08:22:57 -0000 1.4.10.7 @@ -1,5 +1,5 @@ /* - * $Id: ufscommon.cc,v 1.4.10.6 2002/12/06 23:43:03 rbcollins Exp $ + * $Id: ufscommon.cc,v 1.4.10.7 2002/12/13 08:22:57 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -93,7 +93,6 @@ static FILE *commonUfsDirOpenTmpSwapLog(SwapDir *, int *, int *); #if 0 static STLOGOPEN commonUfsDirOpenSwapLog; -static STINIT commonUfsDirInit; static STFREE commonUfsDirFree; static STLOGCLEANSTART commonUfsDirWriteCleanStart; static STLOGCLEANNEXTENTRY commonUfsDirCleanLogNextEntry; @@ -358,23 +357,23 @@ } void -commonUfsDirInit(SwapDir * sd) +UFSSwapDir::init() { static int started_clean_event = 0; static const char *errmsg = "\tFailed to verify one of the swap directories, Check cache.log\n" "\tfor details. Run 'squid -z' to create swap directories\n" "\tif needed, or if running Squid for the first time."; - commonUfsDirInitBitmap(sd); - if (commonUfsDirVerifyCacheDirs(sd) < 0) + commonUfsDirInitBitmap(this); + if (commonUfsDirVerifyCacheDirs(this) < 0) fatal(errmsg); - commonUfsDirOpenSwapLog(sd); - commonUfsDirRebuild(sd); + commonUfsDirOpenSwapLog(this); + commonUfsDirRebuild(this); if (!started_clean_event) { eventAdd("storeDirClean", commonUfsDirCleanEvent, NULL, 15.0, 1); started_clean_event = 1; } - (void) storeDirGetBlkSize(sd->path, &sd->fs.blksize); + (void) storeDirGetBlkSize(this->path, &fs.blksize); } void Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.29 retrieving revision 1.1.20.30 diff -u -r1.1.20.29 -r1.1.20.30 --- squid3/src/ufscommon.h 13 Dec 2002 00:54:48 -0000 1.1.20.29 +++ squid3/src/ufscommon.h 13 Dec 2002 08:22:57 -0000 1.1.20.30 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.29 2002/12/13 00:54:48 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.30 2002/12/13 08:22:57 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -81,6 +81,11 @@ extern STOBJCREATE commonUFSCreate; extern STOBJOPEN commonUFSOpen; +class UFSSwapDir : public SwapDir { +public: + virtual void init(); +}; + #include "RefCount.h" class IORequestor : public RefCountable{ Index: squid3/src/fs/aufs/store_asyncufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_asyncufs.h,v retrieving revision 1.2.12.33 retrieving revision 1.2.12.34 diff -u -r1.2.12.33 -r1.2.12.34 --- squid3/src/fs/aufs/store_asyncufs.h 13 Dec 2002 03:07:09 -0000 1.2.12.33 +++ squid3/src/fs/aufs/store_asyncufs.h 13 Dec 2002 08:22:57 -0000 1.2.12.34 @@ -155,6 +155,10 @@ extern STOBJCLOSE storeAufsClose; extern STOBJUNLINK storeAufsUnlink; +class AUFSSwapDir : public UFSSwapDir +{ +}; + #include "IOStrategy.h" class AufsIO : public UFSStrategy { Index: squid3/src/fs/aufs/store_dir_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_dir_aufs.cc,v retrieving revision 1.2.12.9 retrieving revision 1.2.12.10 diff -u -r1.2.12.9 -r1.2.12.10 --- squid3/src/fs/aufs/store_dir_aufs.cc 12 Dec 2002 22:51:31 -0000 1.2.12.9 +++ squid3/src/fs/aufs/store_dir_aufs.cc 13 Dec 2002 08:22:57 -0000 1.2.12.10 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.9 2002/12/12 22:51:31 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.10 2002/12/13 08:22:57 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -190,7 +190,6 @@ aioinfo->map = NULL; /* Debugging purposes */ aioinfo->suggest = 0; aioinfo->io.storeDirUnlinkFile = storeAufsDirIOUnlinkFile; - sd->init = commonUfsDirInit; sd->newfs = commonUfsDirNewfs; sd->dump = storeAufsDirDump; sd->freefs = commonUfsDirFree; @@ -234,7 +233,7 @@ static SwapDir * storeAufsNew(void) { - SwapDir *result = new SwapDir; + SwapDir *result = new AUFSSwapDir; result->IO = &AufsIO::Instance; return result; } Index: squid3/src/fs/coss/store_coss.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/coss/store_coss.h,v retrieving revision 1.3.10.9 retrieving revision 1.3.10.10 diff -u -r1.3.10.9 -r1.3.10.10 --- squid3/src/fs/coss/store_coss.h 11 Dec 2002 21:45:23 -0000 1.3.10.9 +++ squid3/src/fs/coss/store_coss.h 13 Dec 2002 08:22:58 -0000 1.3.10.10 @@ -92,7 +92,6 @@ extern MemPool *coss_membuf_pool; extern MemPool *coss_index_pool; -#include "SwapDir.h" /* * Store IO stuff */ @@ -102,6 +101,11 @@ extern STOBJUNLINK storeCossUnlink; extern STSYNC storeCossSync; +class CossSwapDir : public SwapDir +{ + virtual void init(); +}; + extern off_t storeCossAllocate(SwapDir * SD, const StoreEntry * e, int which); extern void storeCossAdd(SwapDir *, StoreEntry *); extern void storeCossRemove(SwapDir *, StoreEntry *); Index: squid3/src/fs/coss/store_dir_coss.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/coss/store_dir_coss.cc,v retrieving revision 1.4.10.6 retrieving revision 1.4.10.7 diff -u -r1.4.10.6 -r1.4.10.7 --- squid3/src/fs/coss/store_dir_coss.cc 11 Dec 2002 21:45:23 -0000 1.4.10.6 +++ squid3/src/fs/coss/store_dir_coss.cc 13 Dec 2002 08:22:58 -0000 1.4.10.7 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.4.10.6 2002/12/11 21:45:23 rbcollins Exp $ + * $Id: store_dir_coss.cc,v 1.4.10.7 2002/12/13 08:22:58 rbcollins Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -76,7 +76,6 @@ static void storeCossDirCloseTmpSwapLog(SwapDir * sd); static FILE *storeCossDirOpenTmpSwapLog(SwapDir *, int *, int *); static STLOGOPEN storeCossDirOpenSwapLog; -static STINIT storeCossDirInit; static STLOGCLEANSTART storeCossDirWriteCleanStart; static STLOGCLEANNEXTENTRY storeCossDirCleanLogNextEntry; static STLOGCLEANWRITE storeCossDirWriteCleanEntry; @@ -152,20 +151,20 @@ cs->swaplog_fd = -1; } -static void -storeCossDirInit(SwapDir * sd) +void +CossSwapDir::init() { - CossInfo *cs = (CossInfo *) sd->fsdata; + CossInfo *cs = (CossInfo *) fsdata; a_file_setupqueue(&cs->aq); - storeCossDirOpenSwapLog(sd); - storeCossDirRebuild(sd); - cs->fd = file_open(sd->path, O_RDWR | O_CREAT); + storeCossDirOpenSwapLog(this); + storeCossDirRebuild(this); + cs->fd = file_open(path, O_RDWR | O_CREAT); if (cs->fd < 0) { - debug(47, 1) ("%s: %s\n", sd->path, xstrerror()); + debug(47, 1) ("%s: %s\n", path, xstrerror()); fatal("storeCossDirInit: Failed to open a COSS directory."); } n_coss_dirs++; - (void) storeDirGetBlkSize(sd->path, &sd->fs.blksize); + (void) storeDirGetBlkSize(path, &fs.blksize); } void @@ -763,7 +762,6 @@ cs->fd = -1; cs->swaplog_fd = -1; - sd->init = storeCossDirInit; sd->newfs = storeCossDirNewfs; sd->dump = storeCossDirDump; sd->freefs = storeCossDirShutdown; @@ -890,7 +888,7 @@ static SwapDir * storeCossNew(void) { - SwapDir *result = new SwapDir; + SwapDir *result = new CossSwapDir; result->IO = &COSSIO::Instance; return result; } Index: squid3/src/fs/diskd/store_dir_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_dir_diskd.cc,v retrieving revision 1.2.16.16 retrieving revision 1.2.16.17 diff -u -r1.2.16.16 -r1.2.16.17 --- squid3/src/fs/diskd/store_dir_diskd.cc 11 Dec 2002 21:45:23 -0000 1.2.16.16 +++ squid3/src/fs/diskd/store_dir_diskd.cc 13 Dec 2002 08:22:58 -0000 1.2.16.17 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.2.16.16 2002/12/11 21:45:23 rbcollins Exp $ + * $Id: store_dir_diskd.cc,v 1.2.16.17 2002/12/13 08:22:58 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -50,7 +50,6 @@ static int diskd_initialised = 0; -static STINIT storeDiskdDirInit; static STDUMP storeDiskdDirDump; static STCHECKOBJ storeDiskdDirCheckObj; static void storeDiskdDirStats(SwapDir *, StoreEntry *); @@ -63,8 +62,8 @@ -static void -storeDiskdDirInit(SwapDir * sd) +void +DiskdSwapDir::init() { int x; int rfd; @@ -73,21 +72,21 @@ char skey1[32]; char skey2[32]; char skey3[32]; - DiskdIO *IO = dynamic_cast(sd->IO); + DiskdIO *DIO = dynamic_cast(IO); - ikey = (getpid() << 10) + (sd->index << 2); + ikey = (getpid() << 10) + (index << 2); ikey &= 0x7fffffff; - IO->smsgid = msgget((key_t) ikey, 0700 | IPC_CREAT); - if (IO->smsgid < 0) { + DIO->smsgid = msgget((key_t) ikey, 0700 | IPC_CREAT); + if (DIO->smsgid < 0) { debug(50, 0) ("storeDiskdInit: msgget: %s\n", xstrerror()); fatal("msgget failed"); } - IO->rmsgid = msgget((key_t) (ikey + 1), 0700 | IPC_CREAT); - if (IO->rmsgid < 0) { + DIO->rmsgid = msgget((key_t) (ikey + 1), 0700 | IPC_CREAT); + if (DIO->rmsgid < 0) { debug(50, 0) ("storeDiskdInit: msgget: %s\n", xstrerror()); fatal("msgget failed"); } - IO->shm.init(ikey, IO->magic2); + DIO->shm.init(ikey, DIO->magic2); snprintf(skey1, 32, "%d", ikey); snprintf(skey2, 32, "%d", ikey + 1); snprintf(skey3, 32, "%d", ikey + 2); @@ -101,16 +100,16 @@ args, "diskd", &rfd, - &IO->wfd); + &DIO->wfd); if (x < 0) fatalf("execl: %s", Config.Program.diskd); - if (rfd != IO->wfd) + if (rfd != DIO->wfd) comm_close(rfd); - fd_note(IO->wfd, "squid -> diskd"); - commSetTimeout(IO->wfd, -1, NULL, NULL); - commSetNonBlocking(IO->wfd); + fd_note(DIO->wfd, "squid -> diskd"); + commSetTimeout(DIO->wfd, -1, NULL, NULL); + commSetNonBlocking(DIO->wfd); - commonUfsDirInit (sd); + UFSSwapDir::init(); comm_quick_poll_required(); } @@ -398,7 +397,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeDiskdDirIOUnlinkFile; - sd->init = storeDiskdDirInit; sd->newfs = commonUfsDirNewfs; sd->dump = storeDiskdDirDump; sd->freefs = commonUfsDirFree; @@ -439,7 +437,7 @@ static SwapDir * storeDiskdNew(void) { - SwapDir *result = new SwapDir; + SwapDir *result = new DiskdSwapDir; result->IO = new DiskdIO; return result; } Index: squid3/src/fs/diskd/store_diskd.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_diskd.h,v retrieving revision 1.1.20.33 retrieving revision 1.1.20.34 diff -u -r1.1.20.33 -r1.1.20.34 --- squid3/src/fs/diskd/store_diskd.h 12 Dec 2002 11:39:15 -0000 1.1.20.33 +++ squid3/src/fs/diskd/store_diskd.h 13 Dec 2002 08:22:58 -0000 1.1.20.34 @@ -137,6 +137,11 @@ extern STOBJCLOSE storeDiskdClose; extern STOBJUNLINK storeDiskdUnlink; +class DiskdSwapDir : public UFSSwapDir +{ + virtual void init(); +}; + #define SHMBUF_BLKSZ SM_PAGE_SIZE extern diskd_stats_t diskd_stats; Index: squid3/src/fs/null/store_null.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/null/store_null.cc,v retrieving revision 1.1.20.5 retrieving revision 1.1.20.6 diff -u -r1.1.20.5 -r1.1.20.6 --- squid3/src/fs/null/store_null.cc 5 Dec 2002 12:57:33 -0000 1.1.20.5 +++ squid3/src/fs/null/store_null.cc 13 Dec 2002 08:22:58 -0000 1.1.20.6 @@ -1,6 +1,6 @@ /* - * $Id: store_null.cc,v 1.1.20.5 2002/12/05 12:57:33 rbcollins Exp $ + * $Id: store_null.cc,v 1.1.20.6 2002/12/13 08:22:58 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -51,8 +51,12 @@ static NullIO Instance; }; +class NullSwapDir : public SwapDir +{ + virtual void init(); +}; + static int null_initialised = 0; -static void storeNullDirInit(SwapDir * sd); static void storeNullDirStats(SwapDir * SD, StoreEntry * sentry); static STCHECKOBJ storeNullDirCheckObj; static STFSRECONFIGURE storeNullDirReconfigure; @@ -97,7 +101,7 @@ static SwapDir * storeNullNew(void) { - SwapDir *result = new SwapDir; + SwapDir *result = new NullSwapDir; result->IO = &NullIO::Instance; return result; } @@ -108,8 +112,8 @@ (void) 0; } -static void -storeNullDirInit(SwapDir * sd) +void +NullSwapDir::init() { store_dirs_rebuilding++; eventAdd("storeNullDirRebuildComplete", storeNullDirRebuildComplete, @@ -149,7 +153,6 @@ sd->index = index; sd->path = xstrdup(path); sd->statfs = storeNullDirStats; - sd->init = storeNullDirInit; sd->checkobj = storeNullDirCheckObj; sd->log.clean.start = storeNullDirWriteCleanStart; sd->log.clean.done = storeNullDirWriteCleanDone; Index: squid3/src/fs/ufs/store_dir_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_dir_ufs.cc,v retrieving revision 1.1.20.7 retrieving revision 1.1.20.8 diff -u -r1.1.20.7 -r1.1.20.8 --- squid3/src/fs/ufs/store_dir_ufs.cc 11 Dec 2002 21:45:23 -0000 1.1.20.7 +++ squid3/src/fs/ufs/store_dir_ufs.cc 13 Dec 2002 08:22:58 -0000 1.1.20.8 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.1.20.7 2002/12/11 21:45:23 rbcollins Exp $ + * $Id: store_dir_ufs.cc,v 1.1.20.8 2002/12/13 08:22:58 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -171,7 +171,6 @@ ufsinfo->map = NULL; /* Debugging purposes */ ufsinfo->suggest = 0; ufsinfo->io.storeDirUnlinkFile = storeUfsDirIOUnlinkFile; - sd->init = commonUfsDirInit; sd->newfs = commonUfsDirNewfs; sd->dump = storeUfsDirDump; sd->freefs = commonUfsDirFree; @@ -212,7 +211,7 @@ static SwapDir * storeUfsNew(void) { - SwapDir *result = new SwapDir; + SwapDir *result = new UFSSwapDir; result->IO = &UfsIO::Instance; return result; } Index: squid3/src/fs/ufs/store_ufs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/Attic/store_ufs.h,v retrieving revision 1.1.20.24 retrieving revision 1.1.20.25 diff -u -r1.1.20.24 -r1.1.20.25 --- squid3/src/fs/ufs/store_ufs.h 12 Dec 2002 11:39:15 -0000 1.1.20.24 +++ squid3/src/fs/ufs/store_ufs.h 13 Dec 2002 08:22:58 -0000 1.1.20.25 @@ -57,6 +57,7 @@ */ extern STOBJCLOSE storeUfsClose; extern STOBJUNLINK storeUfsUnlink; + #include "IOStrategy.h" class UfsIO : public UFSStrategy {