]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/Strand.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / ipc / Strand.cc
index d6b7d8c12688596760568fd2a9e3159e32e031c0..420cb69233524d54cdca9c7cb646c83b7b0ab38c 100644 (file)
@@ -1,23 +1,33 @@
 /*
- * $Id$
- *
- * DEBUG: section 54    Interprocess Communication
+ * Copyright (C) 1996-2017 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.
  */
 
-#include "config.h"
+/* DEBUG: section 54    Interprocess Communication */
+
+#include "squid.h"
 #include "base/Subscription.h"
 #include "base/TextException.h"
+#include "CacheManager.h"
+#include "CollapsedForwarding.h"
 #include "comm/Connection.h"
-#include "ipc/Strand.h"
-#include "ipc/StrandCoord.h"
+#include "fatal.h"
+#include "globals.h"
+#include "ipc/Kids.h"
 #include "ipc/Messages.h"
 #include "ipc/SharedListen.h"
-#include "ipc/Kids.h"
+#include "ipc/Strand.h"
+#include "ipc/StrandCoord.h"
+#include "ipc/StrandSearch.h"
+#include "mgr/Forwarder.h"
 #include "mgr/Request.h"
 #include "mgr/Response.h"
-#include "mgr/Forwarder.h"
-#include "CacheManager.h"
+#if HAVE_DISKIO_MODULE_IPCIO
+#include "DiskIO/IpcIo/IpcIoFile.h" /* XXX: scope boundary violation */
+#endif
 #if SQUID_SNMP
 #include "snmp/Forwarder.h"
 #include "snmp/Request.h"
 
 CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand);
 
-
 Ipc::Strand::Strand():
-        Port(MakeAddr(strandAddrPfx, KidIdentifier)),
-        isRegistered(false)
+    Port(MakeAddr(strandAddrLabel, KidIdentifier)),
+    isRegistered(false)
 {
 }
 
@@ -43,9 +52,11 @@ void Ipc::Strand::registerSelf()
 {
     debugs(54, 6, HERE);
     Must(!isRegistered);
+
+    HereIamMessage ann(StrandCoord(KidIdentifier, getpid()));
     TypedMsgHdr message;
-    StrandCoord(KidIdentifier, getpid()).pack(message);
-    SendMessage(coordinatorAddr, message);
+    ann.pack(message);
+    SendMessage(Port::CoordinatorAddr(), message);
     setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable?
 }
 
@@ -55,13 +66,23 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
     switch (message.type()) {
 
     case mtRegistration:
-        handleRegistrationResponse(StrandCoord(message));
+        handleRegistrationResponse(HereIamMessage(message));
         break;
 
     case mtSharedListenResponse:
         SharedListenJoined(SharedListenResponse(message));
         break;
 
+#if HAVE_DISKIO_MODULE_IPCIO
+    case mtStrandSearchResponse:
+        IpcIoFile::HandleOpenResponse(StrandSearchResponse(message));
+        break;
+
+    case mtIpcIoNotification:
+        IpcIoFile::HandleNotification(message);
+        break;
+#endif /* HAVE_DISKIO_MODULE_IPCIO */
+
     case mtCacheMgrRequest: {
         const Mgr::Request req(message);
         handleCacheMgrRequest(req);
@@ -74,6 +95,10 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
     }
     break;
 
+    case mtCollapsedForwardingNotification:
+        CollapsedForwarding::HandleNotification(message);
+        break;
+
 #if SQUID_SNMP
     case mtSnmpRequest: {
         const Snmp::Request req(message);
@@ -89,15 +114,15 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
 #endif
 
     default:
-        debugs(54, 1, HERE << "Unhandled message type: " << message.type());
+        debugs(54, DBG_IMPORTANT, HERE << "Unhandled message type: " << message.type());
         break;
     }
 }
 
-void Ipc::Strand::handleRegistrationResponse(const StrandCoord &strand)
+void Ipc::Strand::handleRegistrationResponse(const HereIamMessage &msg)
 {
     // handle registration response from the coordinator; it could be stale
-    if (strand.kidId == KidIdentifier && strand.pid == getpid()) {
+    if (msg.strand.kidId == KidIdentifier && msg.strand.pid == getpid()) {
         debugs(54, 6, "kid" << KidIdentifier << " registered");
         clearTimeout(); // we are done
     } else {
@@ -139,3 +164,4 @@ void Ipc::Strand::timedout()
     if (!isRegistered)
         fatalf("kid%d registration timed out", KidIdentifier);
 }
+