]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/fs/ufs/UFSStoreState.h
Maintenance: Remove FIXME and \todo labels (#647)
[thirdparty/squid.git] / src / fs / ufs / UFSStoreState.h
index 828efe0dcbccdf85c57c022771778b29c912823f..eeae9b00e3abc7191df371a6d388cbfc19faa68e 100644 (file)
@@ -1,46 +1,28 @@
 /*
- * SQUID Web Proxy Cache          http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- *  Squid is the result of efforts by numerous individuals from
- *  the Internet community; see the CONTRIBUTORS file for full
- *  details.   Many organizations have provided support for Squid's
- *  development; see the SPONSORS file for full details.  Squid is
- *  Copyrighted (C) 2001 by the Regents of the University of
- *  California; see the COPYRIGHT file for full details.  Squid
- *  incorporates software developed and/or copyrighted by other
- *  sources; see the CREDITS file for full details.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
 #ifndef SQUID_FS_UFS_UFSSTORESTATE_H
 #define SQUID_FS_UFS_UFSSTORESTATE_H
 
 #include "DiskIO/IORequestor.h"
-#include "SquidList.h"
 #include "StoreIOState.h"
 
+#include <queue>
+
 namespace Fs
 {
 namespace Ufs
 {
-/// \ingroup UFS
+
 class UFSStoreState : public StoreIOState, public IORequestor
 {
+    CBDATA_CLASS(UFSStoreState);
+
 public:
     UFSStoreState(SwapDir * SD, StoreEntry * anEntry, STIOCB * callback_, void *callback_data_);
     ~UFSStoreState();
@@ -65,28 +47,60 @@ protected:
 
     class _queued_read
     {
-    public:
         MEMPROXY_CLASS(UFSStoreState::_queued_read);
+    public:
+        _queued_read(char *b, size_t s, off_t o, STRCB *cb, void *data) :
+            buf(b),
+            size(s),
+            offset(o),
+            callback(cb),
+            callback_data(cbdataReference(data))
+        {}
+        ~_queued_read() {
+            cbdataReferenceDone(callback_data);
+        }
+        _queued_read(const _queued_read &qr) = delete;
+        _queued_read &operator =(const _queued_read &qr) = delete;
+
         char *buf;
         size_t size;
         off_t offset;
         STRCB *callback;
         void *callback_data;
-
     };
+    std::queue<Ufs::UFSStoreState::_queued_read> pending_reads;
 
     class _queued_write
     {
-    public:
         MEMPROXY_CLASS(UFSStoreState::_queued_write);
+    public:
+        _queued_write(const char *b, size_t s, off_t o, FREE *f) :
+            buf(b),
+            size(s),
+            offset(o),
+            free_func(f)
+        {}
+        ~_queued_write() {
+            /*
+              * DPW 2006-05-24
+              * Note "free_func" is memNodeWriteComplete(), which doesn't
+              * really free the memory.  Instead it clears the node's
+              * write_pending flag.
+              */
+            if (free_func && buf)
+                free_func(const_cast<char *>(buf));
+        }
+        _queued_write(const _queued_write &qr) = delete;
+        _queued_write &operator =(const _queued_write &qr) = delete;
+
         char const *buf;
         size_t size;
         off_t offset;
         FREE *free_func;
-
     };
+    std::queue<Ufs::UFSStoreState::_queued_write> pending_writes;
 
-    /** \todo These should be in the IO strategy */
+    // TODO: These should be in the IO strategy
 
     struct {
         /**
@@ -104,10 +118,7 @@ protected:
          */
         bool try_closing;
     } flags;
-    link_list *pending_reads;
-    link_list *pending_writes;
-    void queueRead(char *, size_t, off_t, STRCB *, void *);
-    void queueWrite(char const *, size_t, off_t, FREE *);
+
     bool kickReadQueue();
     void drainWriteQueue();
     void tryClosing();
@@ -117,13 +128,10 @@ private:
     void openDone();
     void freePending();
     void doWrite();
-    CBDATA_CLASS2(UFSStoreState);
 };
 
-MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_read);
-MEMPROXY_CLASS_INLINE(UFSStoreState::_queued_write);
-
 } //namespace Ufs
 } //namespace Fs
 
 #endif /* SQUID_FS_UFS_UFSSTORESTATE_H */
+