]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskdIOStrategy.cc
index ff381464152237a81eb54e1325361c68630b247a..99e85042744cf67afd67f166ab1d0fa5ec0796a0 100644 (file)
@@ -1,51 +1,29 @@
 /*
- * DEBUG: section 79    Squid-side DISKD I/O functions.
- * AUTHOR: Duane Wessels
+ * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
  *
- * 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) 2003, Robert Collins <robertc@squid-cache.org>
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
+/* DEBUG: section 79    Squid-side DISKD I/O functions. */
+
 #include "squid.h"
 #include "comm/Loops.h"
 #include "ConfigOption.h"
+#include "diomsg.h"
+#include "DiskdFile.h"
 #include "DiskdIOStrategy.h"
 #include "DiskIO/DiskFile.h"
-#include "DiskdFile.h"
-#include "diomsg.h"
 #include "fd.h"
-#include "Store.h"
-#include "StatCounters.h"
 #include "SquidConfig.h"
 #include "SquidIpc.h"
 #include "SquidTime.h"
+#include "StatCounters.h"
+#include "Store.h"
 #include "unlinkd.h"
 
+#include <cerrno>
 #if HAVE_SYS_IPC_H
 #include <sys/ipc.h>
 #endif
@@ -55,9 +33,6 @@
 #if HAVE_SYS_SHM_H
 #include <sys/shm.h>
 #endif
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
 
 diskd_stats_t diskd_stats;
 
@@ -111,7 +86,7 @@ DiskdIOStrategy::newFile(char const *path)
     return new DiskdFile (path, this);
 }
 
-DiskdIOStrategy::DiskdIOStrategy() : magic1(64), magic2(72), away(0) , smsgid(-1), rmsgid(-1), wfd(-1) , instanceID(newInstance())
+DiskdIOStrategy::DiskdIOStrategy() : magic1(64), magic2(72), away(0), smsgid(-1), rmsgid(-1), wfd(-1), instanceID(newInstance())
 {}
 
 bool
@@ -149,8 +124,9 @@ DiskdIOStrategy::unlinkFile(char const *path)
              shm_offset);
 
     if (x < 0) {
-        debugs(79, DBG_IMPORTANT, "storeDiskdSend UNLINK: " << xstrerror());
-        ::unlink(buf);         /* XXX EWW! */
+        int xerrno = errno;
+        debugs(79, DBG_IMPORTANT, "storeDiskdSend UNLINK: " << xstrerr(xerrno));
+        ::unlink(buf);      /* XXX EWW! */
         //        shm.put (shm_offset);
     }
 
@@ -175,14 +151,16 @@ DiskdIOStrategy::init()
     smsgid = msgget((key_t) ikey, 0700 | IPC_CREAT);
 
     if (smsgid < 0) {
-        debugs(50, DBG_CRITICAL, "storeDiskdInit: msgget: " << xstrerror());
+        int xerrno = errno;
+        debugs(50, DBG_CRITICAL, MYNAME << "msgget: " << xstrerr(xerrno));
         fatal("msgget failed");
     }
 
     rmsgid = msgget((key_t) (ikey + 1), 0700 | IPC_CREAT);
 
     if (rmsgid < 0) {
-        debugs(50, DBG_CRITICAL, "storeDiskdInit: msgget: " << xstrerror());
+        int xerrno = errno;
+        debugs(50, DBG_CRITICAL, MYNAME << "msgget: " << xstrerr(xerrno));
         fatal("msgget failed");
     }
 
@@ -195,7 +173,7 @@ DiskdIOStrategy::init()
     args[2] = skey2;
     args[3] = skey3;
     args[4] = NULL;
-    localhost.SetLocalhost();
+    localhost.setLocalhost();
     pid = ipcCreate(IPC_STREAM,
                     Config.Program.diskd,
                     args,
@@ -273,14 +251,16 @@ SharedMemory::init(int ikey, int magic2)
                 nbufs * SHMBUF_BLKSZ, 0600 | IPC_CREAT);
 
     if (id < 0) {
-        debugs(50, DBG_CRITICAL, "storeDiskdInit: shmget: " << xstrerror());
+        int xerrno = errno;
+        debugs(50, DBG_CRITICAL, MYNAME << "shmget: " << xstrerr(xerrno));
         fatal("shmget failed");
     }
 
     buf = (char *)shmat(id, NULL, 0);
 
     if (buf == (void *) -1) {
-        debugs(50, DBG_CRITICAL, "storeDiskdInit: shmat: " << xstrerror());
+        int xerrno = errno;
+        debugs(50, DBG_CRITICAL, MYNAME << "shmat: " << xstrerr(xerrno));
         fatal("shmat failed");
     }
 
@@ -405,7 +385,8 @@ DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, size_t size, off_t offset, s
         ++diskd_stats.sent_count;
         ++away;
     } else {
-        debugs(79, DBG_IMPORTANT, "storeDiskdSend: msgsnd: " << xstrerror());
+        int xerrno = errno;
+        debugs(79, DBG_IMPORTANT, MYNAME << "msgsnd: " << xstrerr(xerrno));
         cbdataReferenceDone(M->callback_data);
         ++send_errors;
         assert(send_errors < 100);
@@ -563,7 +544,7 @@ DiskdIOStrategy::callback()
     }
 
     while (1) {
-#ifdef ALWAYS_ZERO_BUFFERS
+#ifdef  ALWAYS_ZERO_BUFFERS
         memset(&M, '\0', sizeof(M));
 #endif
 
@@ -579,7 +560,7 @@ DiskdIOStrategy::callback()
         ++diskd_stats.recv_count;
         --away;
         handle(&M);
-        retval = 1;            /* Return that we've actually done some work */
+        retval = 1;     /* Return that we've actually done some work */
 
         if (M.shm_offset > -1)
             shm.put ((off_t) M.shm_offset);
@@ -593,3 +574,4 @@ DiskdIOStrategy::statfs(StoreEntry & sentry)const
 {
     storeAppendPrintf(&sentry, "Pending operations: %d\n", away);
 }
+