--------------------- PatchSet 245 Date: 2002/12/04 09:05:45 Author: rbcollins Branch: unify-io Tag: (none) Log: fixi cbdata issue caused in last commit Members: src/fs/diskd/store_io_diskd.cc:1.1.20.5->1.1.20.6 src/fs/ufs/store_io_ufs.cc:1.3.10.4->1.3.10.5 test-suite/Makefile.am:1.2->1.2.10.1 Index: squid3/src/fs/diskd/store_io_diskd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/diskd/Attic/store_io_diskd.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/diskd/store_io_diskd.cc 3 Dec 2002 12:25:58 -0000 1.1.20.5 +++ squid3/src/fs/diskd/store_io_diskd.cc 4 Dec 2002 09:05:45 -0000 1.1.20.6 @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.1.20.5 2002/12/03 12:25:58 rbcollins Exp $ + * $Id: store_io_diskd.cc,v 1.1.20.6 2002/12/04 09:05:45 rbcollins Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -45,7 +45,7 @@ #include "SwapDir.h" static int storeDiskdSend(int, SwapDir *, int, StoreIOState::Pointer, int, int, off_t); -static void storeDiskdIOCallback(StoreIOState::Pointer, int errflag); +static void storeDiskdIOCallback(void *siocb, int errflag); /* === PUBLIC =========================================================== */ DiskdIO::DiskdIO() : away (0), magic1(64) @@ -87,12 +87,14 @@ /* Mark result as being owned - we want the refcounter to do the delete * call */ cbdataReference(result); + debug (0,0)("diskdstate with base %p allocating\n", result); return result; } void diskdstate_t::operator delete (void *address) { + debug (0,0)("diskdstate with base %p deleting\n",address); diskdstate_t *t = static_cast(address); cbdataFree(address); /* And allow the memory to be freed */ @@ -107,6 +109,14 @@ id = diskd_stats.sio_id++; } +/* + * We can't pass memFree() as a free function here, because we need to free + * the fsstate variable .. + */ +diskdstate_t::~diskdstate_t() +{ +} + StoreIOState::Pointer storeDiskdOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) @@ -426,6 +436,13 @@ void storeDiskdHandle(diomsg * M) { + if (!cbdataReferenceValid (M->callback_data)) { + debug(79, 3) ("storeDiskdHandle: Invalid callback_data %p\n", + M->callback_data); + cbdataReferenceDone (M->callback_data); + return; + } + switch (M->mtype) { case _MQD_OPEN: storeDiskdOpenDone(M); @@ -446,12 +463,17 @@ assert(0); break; } - M->callback_data = NULL; + cbdataReferenceDone (M->callback_data); } static void -storeDiskdIOCallback(StoreIOState::Pointer sio, int errflag) +storeDiskdIOCallback(void *siocb, int errflag) { + if (!cbdataReferenceValid(siocb)) { + debug (79, 0) ("storeDiskdIOCallback: invalid siocb %p\n",siocb); + return; + } + StoreIOState::Pointer sio = (storeIOState *)siocb; void *cbdata; STIOCB *callback = sio->callback; debug(79, 3) ("storeUfsIOCallback: errflag=%d\n", errflag); @@ -470,7 +492,7 @@ static int seq_no = 0; diskdinfo_t *diskdinfo = (diskdinfo_t *)sd->fsdata; M.mtype = mtype; - M.callback_data = sio.getRaw(); + M.callback_data = cbdataReference(sio.getRaw()); M.size = size; M.offset = offset; M.status = -1; @@ -487,7 +509,7 @@ IO->away++; } else { debug(79, 1) ("storeDiskdSend: msgsnd: %s\n", xstrerror()); - M.callback_data = NULL; + cbdataReferenceDone(M.callback_data); assert(++send_errors < 100); } /* @@ -514,8 +536,3 @@ } -/* - * We can't pass memFree() as a free function here, because we need to free - * the fsstate variable .. - */ -diskdstate_t::~diskdstate_t(){} Index: squid3/src/fs/ufs/store_io_ufs.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fs/ufs/store_io_ufs.cc,v retrieving revision 1.3.10.4 retrieving revision 1.3.10.5 diff -u -r1.3.10.4 -r1.3.10.5 --- squid3/src/fs/ufs/store_io_ufs.cc 3 Dec 2002 11:07:01 -0000 1.3.10.4 +++ squid3/src/fs/ufs/store_io_ufs.cc 4 Dec 2002 09:05:46 -0000 1.3.10.5 @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.3.10.4 2002/12/03 11:07:01 rbcollins Exp $ + * $Id: store_io_ufs.cc,v 1.3.10.5 2002/12/04 09:05:46 rbcollins Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -88,11 +88,10 @@ storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * callback, void *callback_data) { - sfileno f = e->swap_filen; - char *path = commonUfsDirFullPath(SD, f, NULL); + char *path = commonUfsDirFullPath(SD, e->swap_filen, NULL); struct stat sb; int fd; - debug(79, 3) ("storeUfsOpen: fileno %08X\n", f); + debug(79, 3) ("storeUfsOpen: fileno %08X\n", e->swap_filen); fd = file_open(path, O_RDONLY | O_BINARY); if (fd < 0) { debug(79, 3) ("storeUfsOpen: got failure (%d)\n", errno); @@ -101,7 +100,7 @@ debug(79, 3) ("storeUfsOpen: opened FD %d\n", fd); StoreIOState::Pointer sio = new ufsstate_t; - sio->swap_filen = f; + sio->swap_filen = e->swap_filen; sio->swap_dirn = SD->index; sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; Index: squid3/test-suite/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/test-suite/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.10.1 diff -u -r1.2 -r1.2.10.1 --- squid3/test-suite/Makefile.am 22 Nov 2002 03:12:51 -0000 1.2 +++ squid3/test-suite/Makefile.am 4 Dec 2002 09:05:46 -0000 1.2.10.1 @@ -1,9 +1,11 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.2 2002/11/22 03:12:51 squidadm Exp $ +# $Id: Makefile.am,v 1.2.10.1 2002/12/04 09:05:46 rbcollins Exp $ # +AUTOMAKE_OPTIONS = subdir-objects + AM_CFLAGS = -Werror -Wall AM_CXXFLAGS = -Werror -Wall @@ -19,7 +21,6 @@ refcount_SOURCES = refcount.cc - ## membanger won't link today. Bitrot.. ##CC = gcc ##CFLAGS = -g -Wall -I../include -I../src