]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / DiskIO / DiskThreads / DiskThreadsIOStrategy.cc
index 9bd7478c1d115ec4c385ef2af82d06aaf1b71882..3d9bf8b64657aa8a430cc629226eb608d30c0ef6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -9,7 +9,6 @@
 /* DEBUG: section 79    Squid-side Disk I/O functions. */
 
 #include "squid.h"
-
 #include "DiskThreadsDiskFile.h"
 #include "DiskThreadsIOStrategy.h"
 #include "fde.h"
 #include "StatCounters.h"
 #include "Store.h"
 
+/* squidaio_ctrl_t uses explicit alloc()/freeOne().
+ * XXX: convert to MEMPROXY_CLASS() API
+ */
+#include "mem/Pool.h"
+
 void
 DiskThreadsIOStrategy::init(void)
 {
     if (initialised)
         return;
 
-    squidaio_ctrl_pool = memPoolCreate("aio_ctrl", sizeof(squidaio_ctrl_t));
-
     initialised = true;
 
     /*
@@ -52,10 +54,6 @@ DiskThreadsIOStrategy::done(void)
 
     squidaio_shutdown();
 
-    delete squidaio_ctrl_pool;
-
-    squidaio_ctrl_pool = NULL;
-
     initialised = false;
 }
 
@@ -108,7 +106,7 @@ DiskThreadsIOStrategy::callback()
         }
 
         if (ctrlp == NULL)
-            continue;          /* XXX Should not happen */
+            continue;       /* XXX Should not happen */
 
         dlinkDelete(&ctrlp->node, &used_list);
 
@@ -118,7 +116,7 @@ DiskThreadsIOStrategy::callback()
             ctrlp->done_handler = NULL;
 
             if (cbdataReferenceValidDone(ctrlp->done_handler_data, &cbdata)) {
-                retval = 1;    /* Return that we've actually done some work */
+                retval = 1; /* Return that we've actually done some work */
                 done_callback(ctrlp->fd, cbdata, ctrlp->bufp,
                               ctrlp->result.aio_return, ctrlp->result.aio_errno);
             } else {
@@ -140,7 +138,7 @@ DiskThreadsIOStrategy::callback()
         if (ctrlp->operation == _AIO_READ)
             squidaio_xfree(ctrlp->bufp, ctrlp->len);
 
-        squidaio_ctrl_pool->freeOne(ctrlp);
+        delete ctrlp;
     }
 
     return retval;
@@ -151,7 +149,7 @@ void
 DiskThreadsIOStrategy::sync()
 {
     if (!initialised)
-        return;                        /* nothing to do then */
+        return;         /* nothing to do then */
 
     /* Flush all pending operations */
     debugs(32, 2, "aioSync: flushing pending I/O operations");
@@ -164,8 +162,7 @@ DiskThreadsIOStrategy::sync()
 }
 
 DiskThreadsIOStrategy::DiskThreadsIOStrategy() :
-        initialised(false),
-        squidaio_ctrl_pool(NULL)
+    initialised(false)
 {}
 
 void
@@ -228,7 +225,7 @@ DiskThreadsIOStrategy::newFile (char const *path)
         return NULL;
     }
 
-    return new DiskThreadsDiskFile (path, this);
+    return new DiskThreadsDiskFile(path);
 }
 
 bool
@@ -243,3 +240,4 @@ DiskThreadsIOStrategy::unlinkFile(char const *path)
     ++statCounter.syscalls.disk.unlinks;
     aioUnlink(path, NULL, NULL);
 }
+