]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/Strand.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / ipc / Strand.cc
index f6939b4b5ed418efb73c8c9b3dc0a2f67e9fdd75..1339969c52e14a2d39de3b28c92e2107b9eaaec3 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * DEBUG: section 54    Interprocess Communication
+ * 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.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
+/* 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 "fatal.h"
 #include "globals.h"
 #include "ipc/Kids.h"
 #include "ipc/Messages.h"
+#include "ipc/QuestionerId.h"
 #include "ipc/SharedListen.h"
 #include "ipc/Strand.h"
 #include "ipc/StrandCoord.h"
@@ -18,8 +26,7 @@
 #include "mgr/Forwarder.h"
 #include "mgr/Request.h"
 #include "mgr/Response.h"
-#include "SwapDir.h" /* XXX: scope boundary violation */
-#if USE_DISKIO_IPCIO
+#if HAVE_DISKIO_MODULE_IPCIO
 #include "DiskIO/IpcIo/IpcIoFile.h" /* XXX: scope boundary violation */
 #endif
 #if SQUID_SNMP
@@ -31,8 +38,8 @@
 CBDATA_NAMESPACED_CLASS_INIT(Ipc, Strand);
 
 Ipc::Strand::Strand():
-        Port(MakeAddr(strandAddrPfx, KidIdentifier)),
-        isRegistered(false)
+    Port(MakeAddr(strandAddrLabel, KidIdentifier)),
+    isRegistered(false)
 {
 }
 
@@ -47,35 +54,31 @@ void Ipc::Strand::registerSelf()
     debugs(54, 6, HERE);
     Must(!isRegistered);
 
-    HereIamMessage ann(StrandCoord(KidIdentifier, getpid()));
-    TypedMsgHdr message;
-    ann.pack(message);
-    SendMessage(coordinatorAddr, message);
+    StrandMessage::NotifyCoordinator(mtRegisterStrand, nullptr);
     setTimeout(6, "Ipc::Strand::timeoutHandler"); // TODO: make 6 configurable?
 }
 
 void Ipc::Strand::receive(const TypedMsgHdr &message)
 {
-    debugs(54, 6, HERE << message.type());
-    switch (message.type()) {
+    switch (message.rawType()) {
 
-    case mtRegistration:
-        handleRegistrationResponse(HereIamMessage(message));
+    case mtStrandRegistered:
+        handleRegistrationResponse(Mine(StrandMessage(message)));
         break;
 
     case mtSharedListenResponse:
-        SharedListenJoined(SharedListenResponse(message));
+        SharedListenJoined(Mine(SharedListenResponse(message)));
         break;
 
-#if USE_DISKIO_IPCIO
-    case mtStrandSearchResponse:
-        IpcIoFile::HandleOpenResponse(StrandSearchResponse(message));
+#if HAVE_DISKIO_MODULE_IPCIO
+    case mtStrandReady:
+        IpcIoFile::HandleOpenResponse(Mine(StrandMessage(message)));
         break;
 
     case mtIpcIoNotification:
         IpcIoFile::HandleNotification(message);
         break;
-#endif /* USE_DISKIO_IPCIO */
+#endif /* HAVE_DISKIO_MODULE_IPCIO */
 
     case mtCacheMgrRequest: {
         const Mgr::Request req(message);
@@ -85,10 +88,14 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
 
     case mtCacheMgrResponse: {
         const Mgr::Response resp(message);
-        handleCacheMgrResponse(resp);
+        handleCacheMgrResponse(Mine(resp));
     }
     break;
 
+    case mtCollapsedForwardingNotification:
+        CollapsedForwarding::HandleNotification(message);
+        break;
+
 #if SQUID_SNMP
     case mtSnmpRequest: {
         const Snmp::Request req(message);
@@ -98,18 +105,19 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
 
     case mtSnmpResponse: {
         const Snmp::Response resp(message);
-        handleSnmpResponse(resp);
+        handleSnmpResponse(Mine(resp));
     }
     break;
 #endif
 
     default:
-        debugs(54, DBG_IMPORTANT, HERE << "Unhandled message type: " << message.type());
+        Port::receive(message);
         break;
     }
 }
 
-void Ipc::Strand::handleRegistrationResponse(const HereIamMessage &msg)
+void
+Ipc::Strand::handleRegistrationResponse(const StrandMessage &msg)
 {
     // handle registration response from the coordinator; it could be stale
     if (msg.strand.kidId == KidIdentifier && msg.strand.pid == getpid()) {
@@ -154,3 +162,4 @@ void Ipc::Strand::timedout()
     if (!isRegistered)
         fatalf("kid%d registration timed out", KidIdentifier);
 }
+