]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/mem/Segment.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / mem / Segment.cc
index e5f5b5f8ce42bd4e61cc7eb9b384a1f2e1564bae..c2cc40dd7391db644b3b62d784b9b9b21cad9628 100644 (file)
@@ -1,21 +1,34 @@
 /*
- * $Id$
- *
- * DEBUG: section 54    Interprocess Communication
+ * Copyright (C) 1996-2015 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.
  */
 
+/* DEBUG: section 54    Interprocess Communication */
+
 #include "squid.h"
 #include "base/TextException.h"
 #include "compat/shm.h"
+#include "Debug.h"
+#include "fatal.h"
 #include "ipc/mem/Segment.h"
-#include "protos.h"
+#include "SBuf.h"
+#include "tools.h"
 
+#if HAVE_FCNTL_H
 #include <fcntl.h>
+#endif
+#if HAVE_SYS_MMAN_H
 #include <sys/mman.h>
+#endif
+#if HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
-
+#endif
 
 // test cases change this
 const char *Ipc::Mem::Segment::BasePath = DEFAULT_STATEDIR;
@@ -34,11 +47,20 @@ Ipc::Mem::Segment::reserve(size_t chunkSize)
     return result;
 }
 
+SBuf
+Ipc::Mem::Segment::Name(const SBuf &prefix, const char *suffix)
+{
+    SBuf result = prefix;
+    result.append("_");
+    result.append(suffix);
+    return result;
+}
+
 #if HAVE_SHM
 
 Ipc::Mem::Segment::Segment(const char *const id):
-        theFD(-1), theName(GenerateName(id)), theMem(NULL),
-        theSize(0), theReserved(0), doUnlink(false)
+    theFD(-1), theName(GenerateName(id)), theMem(NULL),
+    theSize(0), theReserved(0), doUnlink(false)
 {
 }
 
@@ -210,7 +232,7 @@ typedef std::map<String, Ipc::Mem::Segment *> SegmentMap;
 static SegmentMap Segments;
 
 Ipc::Mem::Segment::Segment(const char *const id):
-        theName(id), theMem(NULL), theSize(0), theReserved(0), doUnlink(false)
+    theName(id), theMem(NULL), theSize(0), theReserved(0), doUnlink(false)
 {
 }
 
@@ -280,7 +302,7 @@ Ipc::Mem::Segment::checkSupport(const char *const context)
 #endif // HAVE_SHM
 
 void
-Ipc::Mem::RegisteredRunner::run(const RunnerRegistry &r)
+Ipc::Mem::RegisteredRunner::useConfig()
 {
     // If Squid is built with real segments, we create() real segments
     // in the master process only.  Otherwise, we create() fake
@@ -291,10 +313,11 @@ Ipc::Mem::RegisteredRunner::run(const RunnerRegistry &r)
 #else
     if (IamWorkerProcess())
 #endif
-        create(r);
+        create();
 
     // we assume that master process does not need shared segments
     // unless it is also a worker
     if (!InDaemonMode() || !IamMasterProcess())
-        open(r);
+        open();
 }
+