--------------------- PatchSet 312 Date: 2002/12/10 23:09:38 Author: rbcollins Branch: unify-io Tag: (none) Log: move queued_read into UFSStoreState Members: src/ufscommon.h:1.1.20.15->1.1.20.16 src/fs/aufs/store_asyncufs.h:1.2.12.18->1.2.12.19 src/fs/aufs/store_dir_aufs.cc:1.2.12.5->1.2.12.6 src/fs/aufs/store_io_aufs.cc:1.3.12.20->1.3.12.21 Index: squid3/src/ufscommon.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ufscommon.h,v retrieving revision 1.1.20.15 retrieving revision 1.1.20.16 diff -u -r1.1.20.15 -r1.1.20.16 --- squid3/src/ufscommon.h 10 Dec 2002 22:38:14 -0000 1.1.20.15 +++ squid3/src/ufscommon.h 10 Dec 2002 23:09:38 -0000 1.1.20.16 @@ -1,6 +1,6 @@ /* - * $Id: ufscommon.h,v 1.1.20.15 2002/12/10 22:38:14 rbcollins Exp $ + * $Id: ufscommon.h,v 1.1.20.16 2002/12/10 23:09:38 rbcollins Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -136,6 +136,18 @@ bool reading; bool writing; protected: + class _queued_read { + public: + void *operator new(size_t); + void operator delete (void *); + char *buf; + size_t size; + off_t offset; + STRCB *callback; + void *callback_data; + private: + static MemPool *Pool; + }; }; #endif /* SQUID_UFSCOMMON_H */ 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.18 retrieving revision 1.2.12.19 diff -u -r1.2.12.18 -r1.2.12.19 --- squid3/src/fs/aufs/store_asyncufs.h 10 Dec 2002 22:38:14 -0000 1.2.12.18 +++ squid3/src/fs/aufs/store_asyncufs.h 10 Dec 2002 23:09:38 -0000 1.2.12.19 @@ -137,6 +137,7 @@ void closeCompleted(); void readCompleted(const char *buf, int len, int errflag); void queueRead(char *, size_t, off_t, STRCB *, void *); + bool kickReadQueue(); private: CBDATA_CLASS(squidaiostate_t); void openDone(); @@ -149,16 +150,7 @@ FREE *free_func; }; -struct _queued_read { - char *buf; - size_t size; - off_t offset; - STRCB *callback; - void *callback_data; -}; - /* The squidaio_state memory pools */ -extern MemPool *aufs_qread_pool; extern MemPool *aufs_qwrite_pool; /* 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.5 retrieving revision 1.2.12.6 diff -u -r1.2.12.5 -r1.2.12.6 --- squid3/src/fs/aufs/store_dir_aufs.cc 7 Dec 2002 01:25:38 -0000 1.2.12.5 +++ squid3/src/fs/aufs/store_dir_aufs.cc 10 Dec 2002 23:09:38 -0000 1.2.12.6 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.2.12.5 2002/12/07 01:25:38 rbcollins Exp $ + * $Id: store_dir_aufs.cc,v 1.2.12.6 2002/12/10 23:09:38 rbcollins Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -249,8 +249,6 @@ storefs->reconfigurefunc = storeAufsDirReconfigure; storefs->donefunc = storeAufsDirDone; storefs->newfunc = storeAufsNew; - aufs_qread_pool = memPoolCreate("AUFS Queued read data", - sizeof(queued_read)); aufs_qwrite_pool = memPoolCreate("AUFS Queued write data", sizeof(queued_write)); Index: squid3/src/fs/aufs/store_io_aufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/aufs/Attic/store_io_aufs.cc,v retrieving revision 1.3.12.20 retrieving revision 1.3.12.21 diff -u -r1.3.12.20 -r1.3.12.21 --- squid3/src/fs/aufs/store_io_aufs.cc 10 Dec 2002 11:45:08 -0000 1.3.12.20 +++ squid3/src/fs/aufs/store_io_aufs.cc 10 Dec 2002 23:09:38 -0000 1.3.12.21 @@ -263,13 +263,30 @@ return fd > -1; } +MemPool * UFSStoreState::_queued_read::Pool = NULL; + +void * +UFSStoreState::_queued_read::operator new(size_t size) +{ + if (!Pool) + Pool = memPoolCreate("AUFS Queued read data",sizeof (_queued_read)); + return memPoolAlloc (Pool); +} + +void +UFSStoreState::_queued_read::operator delete (void *address) +{ + memPoolFree (Pool, address); +} + + void squidaiostate_t::queueRead(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) { debug(79, 3) ("squidaiostate_t::queueRead: queueing read\n"); assert(opening); assert (pending_reads == NULL); - _queued_read *q = (struct _queued_read *)memPoolAlloc(aufs_qread_pool); + _queued_read *q = new _queued_read; q->buf = buf; q->size = size; q->offset = offset; @@ -368,20 +385,19 @@ return 1; } -static int -storeAufsKickReadQueue(storeIOState * sio) +bool +squidaiostate_t::kickReadQueue() { - squidaiostate_t *aiostate = dynamic_cast (sio); - struct _queued_read *q = (struct _queued_read *)linklistShift(&(aiostate->pending_reads)); + struct _queued_read *q = (struct _queued_read *)linklistShift(&pending_reads); void *cbdata; if (NULL == q) - return 0; + return false; debug(79, 3) ("storeAufsKickReadQueue: reading queued request of %ld bytes\n", (long int) q->size); if (cbdataReferenceValidDone(q->callback_data, &cbdata)) - storeAufsRead(INDEXSD(sio->swap_dirn), sio, q->buf, q->size, q->offset, q->callback, cbdata); - memPoolFree(aufs_qread_pool, q); - return 1; + storeAufsRead(INDEXSD(swap_dirn), this, q->buf, q->size, q->offset, q->callback, cbdata); + delete q; + return true; } #if ASYNC_READ @@ -560,7 +576,7 @@ } while ((qr = (struct _queued_read *)linklistShift(&pending_reads))) { cbdataReferenceDone(qr->callback_data); - memPoolFree(aufs_qread_pool, qr); + delete qr; } } @@ -598,7 +614,7 @@ if (storeAufsKickWriteQueue(this)) return; } else if ((FILE_MODE(mode) == O_RDONLY) && !closing) { - if (storeAufsKickReadQueue(this)) + if (kickReadQueue()) return; } if (closing)