]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix assertion in DskIO and Ufs unit tests
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 14 Nov 2008 16:14:29 +0000 (05:14 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 14 Nov 2008 16:14:29 +0000 (05:14 +1300)
Classes whose initialization is implied from the presence of a soliton
do not get initialized when their soliton is hidden away in a library.
Only when the object is linked to a main app.

DiskIO modules are such and require a hook to probe the soliton before
initialization kicks off. This patch adds such a hook function which is
called from the manager setup function to probe all built modules and
ensure their existance and registration is done before initializing.

Also adds a lot of function documentation in various places.

configure.in
src/DiskIO/Blocking/BlockingDiskIOModule.h
src/DiskIO/DiskIOModule.cc
src/DiskIO/DiskIOModule.h
src/DiskIO/modules.sh [new file with mode: 0755]
src/Makefile.am
src/mem.cc
src/tests/testDiskIO.cc

index 92dfc6a810c4f0266fbfd83dfce5a894c638d878..7aad78009f3dd0cc7c288ce363fc84c8e4b5e96f 100644 (file)
@@ -549,15 +549,17 @@ AC_SUBST(STORE_TESTS)
 AC_ARG_ENABLE(disk-io,
   AC_HELP_STRING([--enable-disk-io="list of modules"],
                  [Build support for the list of disk I/O modules.
-                  The default is only to build the "Blocking" module.
+                  If unset only the "Blocking" module will be built.
+                  Set without a value all available modules will be built.
                   See src/DiskIO for a list of available modules, or
-                  Programmers Guide section <not yet written>
+                  Programmers Guide section on DiskIO
                   for details on how to build your custom disk module]),
 [ case $enableval in
   yes)
        for dir in $srcdir/src/DiskIO/*; do
            module="`basename $dir`"
            if test -d "$dir" && test "$module" != CVS; then
+               echo "Autodetected $module DiskIO module"
                DISK_MODULES="$DISK_MODULES $module"
            fi
        done
@@ -574,6 +576,7 @@ AC_ARG_ENABLE(disk-io,
 ],
 [ if test -z "$DISK_MODULES"; then
     DISK_MODULES="Blocking"
+    echo "Enabling Blocking DiskIO module (required default)"
     AC_DEFINE(USE_DISKIO,1,[DiskIO modules are expected to be available.])
   fi
 ])
@@ -588,6 +591,7 @@ if test -n "$DISK_MODULES"; then
     DISK_LIBS="lib`echo $DISK_MODULES|sed -e 's% %.a lib%g'`.a"
     DISK_LINKOBJS=
     for module in $DISK_MODULES; do
+        echo "Enabling $module DiskIO module"
         DISK_LINKOBJS="$DISK_LINKOBJS DiskIO/${module}/${module}DiskIOModule.o"
     done
 fi
@@ -672,7 +676,7 @@ for fs in $DISK_MODULES none; do
        ;;
     esac
 done
-
+AC_SUBST(DISK_MODULES)
 AC_SUBST(DISK_LIBS)
 AC_SUBST(DISK_PROGRAMS)
 AC_SUBST(DISK_LINKOBJS)
index 7be1dc5139dd1321d21b9636a862788877b50f9e..c73df990cb39acda1f6f8b2475082b692acb9d95 100644 (file)
@@ -51,6 +51,4 @@ private:
     static BlockingDiskIOModule Instance;
 };
 
-
-
 #endif /* SQUID_BLOCKINGDISKIOMODULE_H */
index a7636c5b4f5ee369e04f29073c44b3f952fa0b12..48a58c9ced6164f75f1e6d0d26375e53abf18bcf 100644 (file)
@@ -1,6 +1,4 @@
-
 /*
- * $Id: DiskIOModule.cc,v 1.3 2006/09/14 00:51:10 robertc Exp $
  *
  * DEBUG: section 92    Storage File System
  * AUTHOR: Robert Collins
 Vector<DiskIOModule*> *DiskIOModule::_Modules = NULL;
 
 //DiskIOModule() : initialised (false) {}
+
 DiskIOModule::DiskIOModule()
 {
-    /* We cannot call
-     * ModuleAdd(*this);
-     * here as the virtual methods are not yet available
+    /** We cannot call ModuleAdd(*this)
+     * here as the virtual methods are not yet available.
+     * We leave that to PokeAllModules() later.
      */
 }
 
 void
 DiskIOModule::SetupAllModules()
 {
+    DiskIOModule::PokeAllModules();
+
     for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
         /* Call the FS to set up capabilities and initialize the FS driver */
         (*i)->init();
@@ -84,8 +85,8 @@ DiskIOModule::GetModules()
     return *_Modules;
 }
 
-/*
- * called when a graceful shutdown is to occur
+/**
+ * Called when a graceful shutdown is to occur
  * of each fs module.
  */
 void
@@ -111,7 +112,7 @@ DiskIOModule::Find(char const *type)
 DiskIOModule *
 DiskIOModule::FindDefault()
 {
-    /* Best IO options are in order: */
+    /** Best IO options are in order: */
     DiskIOModule * result;
     result = Find("DiskThreads");
     if (NULL == result)
@@ -122,4 +123,3 @@ DiskIOModule::FindDefault()
         result = Find("Blocking");
     return result;
 }
-
index fafb9699014ee0f6c117d06a174f65f6b482869c..e3801c0ad43bfb155792b4790f8b909e2a592c00 100644 (file)
@@ -50,8 +50,13 @@ public:
     static void SetupAllModules();
     static void ModuleAdd(DiskIOModule &);
     static void FreeAllModules();
+
+    /** Poke all compiled modules for self-setup */
+    static void PokeAllModules();
+
     static DiskIOModule *Find(char const *type);
-    /* find *any* usable disk module. This will look for the 'best'
+
+    /** Find *any* usable disk module. This will look for the 'best'
      * available module for this system.
      */
     static DiskIOModule *FindDefault();
diff --git a/src/DiskIO/modules.sh b/src/DiskIO/modules.sh
new file mode 100755 (executable)
index 0000000..6baebab
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+echo "/* automatically generated by $0 $*"
+echo " * do not edit"
+echo " */"
+echo "#include \"squid.h\""
+echo "#include \"DiskIO/DiskIOModule.h\""
+for module in "$@"; do
+   echo "#include \"DiskIO/${module}/${module}DiskIOModule.h\""
+done
+echo ""
+echo "void DiskIOModule::PokeAllModules(void)"
+echo "{"
+for module in "$@"; do
+   echo "    ${module}DiskIOModule::GetInstance();"
+done
+echo "}"
index 916e310e99a0f5b821976f5905d04746de331fa5..c7a0a538b50419034ca6ac044a08b94db9775b70 100644 (file)
@@ -254,12 +254,6 @@ all_FSMODULES = \
        fs/diskd/StoreFSdiskd.cc \
        fs/ufs/StoreFSufs.cc
 
-all_DISKIOMODULES = \
-       DiskIO/AIO/AIODiskIOModule.cc \
-       DiskIO/Blocking/BlockingDiskIOModule.cc \
-       DiskIO/DiskDaemon/DiskDaemonDiskIOModule.cc \
-       DiskIO/DiskThreads/DiskThreadsDiskIOModule.cc
-
 DISKIO_SOURCE = \
        DiskIO/DiskIOModule.cc \
        DiskIO/ReadRequest.cc \
@@ -270,7 +264,12 @@ DISKIO_SOURCE = \
        DiskIO/DiskIOStrategy.h \
        DiskIO/IORequestor.h \
        DiskIO/DiskIOModule.h \
-       DiskIO/ReadRequest.h
+       DiskIO/ReadRequest.h \
+       DiskIO/DiskIOModules_gen.cc
+
+DiskIO/DiskIOModules_gen.cc: Makefile
+       $(SHELL) $(srcdir)/DiskIO/modules.sh $(DISK_MODULES) > DiskIO/DiskIOModules_gen.cc
+
 
 all_AUTHMODULES = \
        auth/basic/basicScheme.cc \
@@ -284,7 +283,6 @@ all_AUTHMODULES = \
 
 EXTRA_squid_SOURCES = \
        $(all_FSMODULES) \
-       $(all_DISKIOMODULES) \
        $(AIO_WIN32_ALL_SOURCES) \
        $(all_AUTHMODULES) \
        $(ARP_ACL_ALL_SOURCE) \
@@ -1124,7 +1122,7 @@ uninstall-local:
 #      fi
 
 DISTCLEANFILES = cf_gen_defines.h cf.data cf_parser.h squid.conf.default squid.conf.documented \
-       globals.cc string_arrays.c repl_modules.cc 
+       globals.cc string_arrays.c repl_modules.cc DiskIO/DiskIOModules_gen.cc
 
 # stock tools for unit tests - library independent versions of dlink_list 
 # etc.
@@ -1485,6 +1483,7 @@ tests_testDiskIO_LDADD= \
        @SSLLIB@
 tests_testDiskIO_LDFLAGS = $(LIBADD_DL)
 tests_testDiskIO_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \
+       $(SWAP_TEST_DS) \
        @SQUID_CPPUNIT_LA@
 
 ## Tests of the Even module.
index 8a9d8c95ceeb46ebcafc1bed1a1cdb9e4edf2981..1998586bf39868a8c88f3b588ca9fde5fde3bc9d 100644 (file)
@@ -344,8 +344,8 @@ void
 memConfigure(void)
 {
     size_t new_pool_limit;
-    /* set to configured value first */
 
+    /** Set to configured value first */
     if (!Config.onoff.mem_pools)
         new_pool_limit = 0;
     else if (Config.MemPools.limit > 0)
@@ -354,7 +354,7 @@ memConfigure(void)
         new_pool_limit = mem_unlimited_size;
 
 #if 0
-    /*
+    /** \par
      * DPW 2007-04-12
      * No debugging here please because this method is called before
      * the debug log is configured and we'll get the message on
@@ -375,17 +375,22 @@ Mem::Init(void)
 {
     int i;
 
-    /*
+    /** \par
      * NOTE: Mem::Init() is called before the config file is parsed
      * and before the debugging module has been initialized.  Any
      * debug messages here at level 0 or 1 will always be printed
      * on stderr.
      */
 
-    /* set all pointers to null */
+    /** \par
+     * Set all pointers to null. */
     memset(MemPools, '\0', sizeof(MemPools));
-    /*
-     * it does not hurt much to have a lot of pools since sizeof(MemPool) is
+    /**
+     * Then initialize all pools.
+     * \par
+     * Starting with generic 2kB - 64kB buffr pools, then specific object types.
+     * \par
+     * It does not hurt much to have a lot of pools since sizeof(MemPool) is
      * small; someday we will figure out what to do with all the entries here
      * that are never used or used only once; perhaps we should simply use
      * malloc() for those? @?@
@@ -417,8 +422,7 @@ Mem::Init(void)
     memDataInit(MEM_MD5_DIGEST, "MD5 digest", SQUID_MD5_DIGEST_LENGTH, 0);
     MemPools[MEM_MD5_DIGEST]->setChunkSize(512 * 1024);
 
-    /* init string pools */
-
+    /** Lastly init the string pools. */
     for (i = 0; i < mem_str_pool_count; i++) {
         StrPools[i].pool = memPoolCreate(StrPoolsAttrs[i].name, StrPoolsAttrs[i].obj_size);
         StrPools[i].pool->zeroOnPush(false);
@@ -427,6 +431,8 @@ Mem::Init(void)
             debugs(13, 1, "Notice: " << StrPoolsAttrs[i].name << " is " << StrPools[i].pool->objectSize() << " bytes instead of requested " << StrPoolsAttrs[i].obj_size << " bytes");
     }
 
+    /** \par
+     * finally register with the cache manager */
     RegisterWithCacheManager();
 }
 
index fd013b09ebd0e3cf48acf66a92f8b6ae55aa4de9..4e9688f708ca8362c2d194312b27168c7affb317 100644 (file)
@@ -32,8 +32,10 @@ testDiskIO::testFindDefault()
 {
     DiskIOModule * module = DiskIOModule::FindDefault();
 #if USE_DISKIO
+    /* enabled. we expect at least ONE */
     CPPUNIT_ASSERT(module != NULL);
 #else
+    /* disabled. we don't expect ANY */
     CPPUNIT_ASSERT(module == NULL);
 #endif
 }