class. Previously, StoreIOState was just a refcounted storeIOState.
I had concerns that mixed use of refcounted and non-refcounted
StoreIOState may be leading to cases where the object gets referenced
via the old-style pointer after the refcounted version had its count
go to zero and the memory was freed. This came about while
investigating bugzilla #1465.
removed StoreIOState-related prototypes from protos.h, and removed
some typedefs from typedefs.h.
Modified STFNCB (storeSwapInFileNotify, storeSwapOutFileNotify) and
STIOCB (storeSwapOutFileClosed, storeSwapInFileClosed) so that they
no longer take StoreIOState arguments. Their "data" arguments
easily lead to the corresponding StoreIOState. The only thing we
really lose here is the ability to assert that "data->sio" equals
the passed StoreIOState.
/*
- * $Id: DiskdIOStrategy.h,v 1.1 2004/12/20 16:30:38 robertc Exp $
+ * $Id: DiskdIOStrategy.h,v 1.2 2006/05/22 19:58:51 wessels Exp $
*
* DEBUG: section 79 Squid-side DISKD I/O functions.
* AUTHOR: Duane Wessels
};
#include "DiskIO/DiskIOStrategy.h"
+#include "StoreIOState.h"
class DiskFile;
void optionQ1Dump(StoreEntry * e) const;
bool optionQ2Parse(char const *option, const char *value, int reconfiguring);
void optionQ2Dump(StoreEntry * e) const;
- int send(int mtype, int id, RefCount<storeIOState> sio, int size, int offset, off_t shm_offset);
+ int send(int mtype, int id, RefCount<StoreIOState> sio, int size, int offset, off_t shm_offset);
void handle(diomsg * M);
void unlinkDone(diomsg * M);
int magic1;
/*
- * $Id: MemObject.h,v 1.11 2006/01/23 20:04:24 wessels Exp $
+ * $Id: MemObject.h,v 1.12 2006/05/22 19:58:51 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
#define SQUID_MEMOBJECT_H
#include "StoreIOBuffer.h"
+#include "StoreIOState.h"
#include "stmem.h"
#include "CommRead.h"
/*
- * $Id: StoreClient.h,v 1.13 2004/12/27 11:04:36 serassio Exp $
+ * $Id: StoreClient.h,v 1.14 2006/05/22 19:58:51 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
#define SQUID_STORECLIENT_H
#include "StoreIOBuffer.h"
+#include "StoreIOState.h"
typedef void STCB(void *, StoreIOBuffer); /* store callback */
/*
- * $Id: StoreIOState.cc,v 1.4 2003/08/31 12:44:30 robertc Exp $
+ * $Id: StoreIOState.cc,v 1.5 2006/05/22 19:58:51 wessels Exp $
*
* DEBUG: section ?? Swap Dir base object
* AUTHOR: Robert Collins
#include "StoreIOState.h"
void *
-storeIOState::operator new (size_t amount)
+StoreIOState::operator new (size_t amount)
{
assert(0);
return (void *)1;
}
void
-storeIOState::operator delete (void *address){assert (0);}
+StoreIOState::operator delete (void *address){assert (0);}
-storeIOState::storeIOState()
+StoreIOState::StoreIOState()
{
mode = O_BINARY;
}
off_t
-storeIOState::offset() const
+StoreIOState::offset() const
{
return offset_;
}
-storeIOState::~storeIOState()
+StoreIOState::~StoreIOState()
{
debugs(20,3, "StoreIOState::~StoreIOState: " << this);
/*
- * $Id: StoreIOState.h,v 1.6 2003/08/04 22:14:41 robertc Exp $
+ * $Id: StoreIOState.h,v 1.7 2006/05/22 19:58:51 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
#ifndef SQUID_STOREIOSTATE_H
#define SQUID_STOREIOSTATE_H
+/*
+ * STRCB is the "store read callback". STRCB functions are passed
+ * to storeRead(). Examples of STRCB callbacks are:
+ * storeClientReadBody
+ * storeClientReadHeader
+ */
+typedef void STRCB(void *their_data, const char *buf, ssize_t len);
+
+/*
+ * STFNCB is the "store file number callback." It is called when
+ * an underlying storage module has allocated the swap file number
+ * and also indicates that the swap file has been opened for reading
+ * or writing. STFNCB functions are passed to storeCreate() and
+ * storeOpen(). Examples of STFNCB callbacks are:
+ * storeSwapInFileNotify
+ * storeSwapOutFileNotify
+ */
+typedef void STFNCB(void *their_data, int errflag);
+
+/*
+ * STIOCB is the "store close callback" for store files. It is
+ * called when the store file is closed. STIOCB functions are
+ * passed to storeCreate() and storeOpen(). Examples of STIOCB
+ * callbacks are:
+ * storeSwapOutFileClosed
+ * storeSwapInFileClosed
+ */
+typedef void STIOCB(void *their_data, int errflag);
+
#include "RefCount.h"
-class storeIOState : public RefCountable
+class StoreIOState : public RefCountable
{
public:
+ typedef RefCount<StoreIOState> Pointer;
- /* storeIOState does not get mempooled - it's children do */
+ /* StoreIOState does not get mempooled - it's children do */
void *operator new (size_t amount);
void operator delete (void *address);
- virtual ~storeIOState();
+ virtual ~StoreIOState();
- storeIOState();
+ StoreIOState();
off_t offset() const;
flags;
};
-class StoreIOState
-{
-
-public:
- typedef RefCount<storeIOState> Pointer;
-};
+StoreIOState::Pointer storeCreate(StoreEntry *, STFNCB *, STIOCB *, void *);
+StoreIOState::Pointer storeOpen(StoreEntry *, STFNCB *, STIOCB *, void *);
+SQUIDCEXTERN void storeClose(StoreIOState::Pointer);
+SQUIDCEXTERN void storeRead(StoreIOState::Pointer, char *, size_t, off_t, STRCB *, void *);
+SQUIDCEXTERN void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
#endif /* SQUID_STOREIOSTATE_H */
DiskIOStrategy *io;
RefCount<DiskFile> theFile;
char *storeCossMemPointerFromDiskOffset(size_t offset, CossMemBuf ** mb);
- void storeCossMemBufUnlock(storeIOState * e);
+ void storeCossMemBufUnlock(StoreIOState::Pointer);
CossMemBuf *createMemBuf(size_t start, sfileno curfn, int *collision);
sfileno allocate(const StoreEntry * e, int which);
void startMembuf();
/* Per-storeiostate info */
-class CossState : public storeIOState
+class CossState : public StoreIOState
{
public:
/*
- * $Id: store_io_ufs.cc,v 1.29 2006/05/19 16:49:13 wessels Exp $
+ * $Id: store_io_ufs.cc,v 1.30 2006/05/22 19:58:53 wessels Exp $
*
* DEBUG: section 79 Storage Manager UFS Interface
* AUTHOR: Duane Wessels
void *cbdata;
if (cbdataReferenceValidDone(callback_data, &cbdata) && theCallback)
- theCallback(cbdata, errflag, this);
+ theCallback(cbdata, errflag);
/* We are finished with the file as this is on close or error only.*/
/* This must be the last line, as theFile may be the only object holding
/*
- * $Id: ufscommon.h,v 1.3 2005/02/05 22:02:32 serassio Exp $
+ * $Id: ufscommon.h,v 1.4 2006/05/22 19:58:53 wessels Exp $
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
* ----------------------------------------------------------
class ReadRequest;
-class UFSStoreState : public storeIOState, public IORequestor
+class UFSStoreState : public StoreIOState, public IORequestor
{
public:
/*
- * $Id: protos.h,v 1.531 2006/05/10 21:04:24 hno Exp $
+ * $Id: protos.h,v 1.532 2006/05/22 19:58:51 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
/* repl_modules.c */
SQUIDCEXTERN void storeReplSetup(void);
-/* store_io.c */
-#include "StoreIOState.h"
-extern StoreIOState::Pointer storeCreate(StoreEntry *, STFNCB *, STIOCB *, void *);
-extern StoreIOState::Pointer storeOpen(StoreEntry *, STFNCB *, STIOCB *, void *);
-SQUIDCEXTERN void storeClose(StoreIOState::Pointer);
-SQUIDCEXTERN void storeRead(StoreIOState::Pointer, char *, size_t, off_t, STRCB *, void *);
-SQUIDCEXTERN void storeIOWrite(StoreIOState::Pointer, char const *, size_t, off_t, FREE *);
-
/*
* store_log.c
*/
* to select different polices depending on object size or type.
*/
StoreIOState::Pointer
-storeCreate(StoreEntry * e, STIOCB * file_callback, STIOCB * close_callback, void *callback_data)
+storeCreate(StoreEntry * e, STFNCB * file_callback, STIOCB * close_callback, void *callback_data)
{
assert (e);
ssize_t objsize;
/*
- * $Id: store_swapin.cc,v 1.36 2003/10/20 12:34:01 robertc Exp $
+ * $Id: store_swapin.cc,v 1.37 2006/05/22 19:58:51 wessels Exp $
*
* DEBUG: section 20 Storage Manager Swapin Functions
* AUTHOR: Duane Wessels
}
static void
-storeSwapInFileClosed(void *data, int errflag, storeIOState * sio)
+storeSwapInFileClosed(void *data, int errflag)
{
store_client *sc = (store_client *)data;
debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n",
- sio, errflag);
+ sc->swapin_sio.getRaw(), errflag);
sc->swapin_sio = NULL;
- /* why this assert */
if (sc->_callback.pending()) {
assert (errflag <= 0);
}
static void
-storeSwapInFileNotify(void *data, int errflag, storeIOState * sio)
+storeSwapInFileNotify(void *data, int errflag)
{
store_client *sc = (store_client *)data;
StoreEntry *e = sc->entry;
- debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e->swap_filen, e->swap_dirn, sio->swap_filen, sio->swap_dirn);
+ debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e->swap_filen, e->swap_dirn, sc->swapin_sio->swap_filen, sc->swapin_sio->swap_dirn);
- e->swap_filen = sio->swap_filen;
- e->swap_dirn = sio->swap_dirn;
+ e->swap_filen = sc->swapin_sio->swap_filen;
+ e->swap_dirn = sc->swapin_sio->swap_dirn;
}
/*
- * $Id: store_swapout.cc,v 1.103 2006/05/19 17:19:10 wessels Exp $
+ * $Id: store_swapout.cc,v 1.104 2006/05/22 19:58:51 wessels Exp $
*
* DEBUG: section 20 Storage Manager Swapout Functions
* AUTHOR: Duane Wessels
static void storeSwapOutStart(StoreEntry * e);
static STIOCB storeSwapOutFileClosed;
-static STIOCB storeSwapOutFileNotify;
+static STFNCB storeSwapOutFileNotify;
/* start swapping object to disk */
static void
}
static void
-storeSwapOutFileNotify(void *data, int errflag, storeIOState * sio)
+storeSwapOutFileNotify(void *data, int errflag)
{
generic_cbdata *c = (generic_cbdata *)data;
StoreEntry *e = (StoreEntry *)c->data;
MemObject *mem = e->mem_obj;
assert(e->swap_status == SWAPOUT_WRITING);
assert(mem);
- assert(mem->swapout.sio == sio);
+ assert(mem->swapout.sio != NULL);
assert(errflag == 0);
e->swap_filen = mem->swapout.sio->swap_filen;
e->swap_dirn = mem->swapout.sio->swap_dirn;
}
static void
-storeSwapOutFileClosed(void *data, int errflag, storeIOState * sio)
+storeSwapOutFileClosed(void *data, int errflag)
{
generic_cbdata *c = (generic_cbdata *)data;
StoreEntry *e = (StoreEntry *)c->data;
virtual void reconfigure(int, char*);
virtual void init();
virtual int canStore(const StoreEntry&) const;
- virtual RefCount<storeIOState> createStoreIO(StoreEntry&, void
- (*)(void*, int, storeIOState*), void (*)(void*, int, storeIOState*), void*);
- virtual RefCount<storeIOState> openStoreIO(StoreEntry&, void
- (*)(void*, int, storeIOState*), void (*)(void*, int, storeIOState*), void*);
+ virtual RefCount<StoreIOState> createStoreIO(StoreEntry&, void
+ (*)(void*, int), void (*)(void*, int), void*);
+ virtual RefCount<StoreIOState> openStoreIO(StoreEntry&, void
+ (*)(void*, int), void (*)(void*, int), void*);
virtual void parse(int, char*);
virtual StoreSearch *search(String, HttpRequest *);
};
/*
- * $Id: typedefs.h,v 1.185 2006/05/19 23:10:21 wessels Exp $
+ * $Id: typedefs.h,v 1.186 2006/05/22 19:58:51 wessels Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
typedef struct _generic_cbdata generic_cbdata;
-class storeIOState;
-
typedef struct _link_list link_list;
typedef struct _Logfile Logfile;
typedef int READ_HANDLER(int, char *, int);
typedef int WRITE_HANDLER(int, const char *, int);
-typedef void STIOCB(void *their_data, int errflag, storeIOState *);
-typedef void STFNCB(void *their_data, int errflag, storeIOState *);
-typedef void STRCB(void *their_data, const char *buf, ssize_t len);
-
typedef int QS(const void *, const void *); /* qsort */
typedef void STABH(void *);
typedef void ERCB(int fd, void *, size_t);