]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/Coordinator.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / ipc / Coordinator.h
index bc0d8fd765de6c647101ee28d374aab725f38f24..a1111c48b9ba74ca608acaac35350f91a54cbbb9 100644 (file)
@@ -1,23 +1,26 @@
 /*
- * $Id$
- *
- * DEBUG: section 54    Interprocess Communication
+ * Copyright (C) 1996-2018 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 */
+
 #ifndef SQUID_IPC_COORDINATOR_H
 #define SQUID_IPC_COORDINATOR_H
 
-
-#include "Array.h"
 #include "ipc/Messages.h"
 #include "ipc/Port.h"
 #include "ipc/SharedListen.h"
 #include "ipc/StrandCoords.h"
+#include "ipc/StrandSearch.h"
 #include "mgr/forward.h"
 #if SQUID_SNMP
 #include "snmp/forward.h"
 #endif
+#include <list>
 #include <map>
 
 namespace Ipc
@@ -26,6 +29,8 @@ namespace Ipc
 ///  Coordinates shared activities of Strands (Squid processes or threads)
 class Coordinator: public Port
 {
+    CBDATA_CLASS(Coordinator);
+
 public:
     static Coordinator* Instance();
 
@@ -42,7 +47,12 @@ protected:
 
     StrandCoord* findStrand(int kidId); ///< registered strand or NULL
     void registerStrand(const StrandCoord &); ///< adds or updates existing
-    void handleRegistrationRequest(const StrandCoord &); ///< register,ACK
+    void handleRegistrationRequest(const HereIamMessage &); ///< register,ACK
+
+    /// answer the waiting search request
+    void notifySearcher(const StrandSearchRequest &request, const StrandCoord&);
+    /// answers or queues the request if the answer is not yet known
+    void handleSearchRequest(const StrandSearchRequest &request);
 
     /// returns cached socket or calls openListenSocket()
     void handleSharedListenRequest(const SharedListenRequest& request);
@@ -53,12 +63,15 @@ protected:
     void handleSnmpResponse(const Snmp::Response& response);
 #endif
     /// calls comm_open_listener()
-    int openListenSocket(const SharedListenRequest& request, int &errNo);
+    Comm::ConnectionPointer openListenSocket(const SharedListenRequest& request, int &errNo);
 
 private:
     StrandCoords strands_; ///< registered processes and threads
 
-    typedef std::map<OpenListenerParams, int> Listeners; ///< params:fd map
+    typedef std::list<StrandSearchRequest> Searchers; ///< search requests
+    Searchers searchers; ///< yet unanswered search requests in arrival order
+
+    typedef std::map<OpenListenerParams, Comm::ConnectionPointer> Listeners; ///< params:connection map
     Listeners listeners; ///< cached comm_open_listener() results
 
     static Coordinator* TheInstance; ///< the only class instance in existence
@@ -66,11 +79,9 @@ private:
 private:
     Coordinator(const Coordinator&); // not implemented
     Coordinator& operator =(const Coordinator&); // not implemented
-
-    CBDATA_CLASS2(Coordinator);
 };
 
-
 } // namespace Ipc
 
 #endif /* SQUID_IPC_COORDINATOR_H */
+