]> granicus.if.org Git - icinga2/commitdiff
Remove unused code
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 7 Sep 2017 08:39:00 +0000 (10:39 +0200)
committerGunnar Beutner <gunnar.beutner@icinga.com>
Tue, 12 Sep 2017 10:52:49 +0000 (12:52 +0200)
refs #5450

lib/remote/jsonrpcconnection.cpp
lib/remote/jsonrpcconnection.hpp

index 62466160fad0e54bb98625f329a0deef5cb649da..a40d6ea6908a0f5caec0c453196743b02adbae50 100644 (file)
@@ -192,27 +192,8 @@ void JsonRpcConnection::MessageHandler(const String& jsonString)
                if (!message->Get("id", &vid))
                        return;
 
-               String id = vid;
-
-               ApiCallbackInfo aci;
-
-               {
-                       boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
-                       auto it = m_ApiCallbacks.find(id);
-
-                       if (it == m_ApiCallbacks.end())
-                               return;
-
-                       aci = it->second;
-                       m_ApiCallbacks.erase(it);
-               }
-
-               try {
-                       aci.Callback(message);
-               } catch (const std::exception& ex) {
-                       Log(LogWarning, "JsonRpcConnection")
-                           << "Error while processing message for identity '" << m_Identity << "'\n" << DiagnosticInformation(ex);
-               }
+               Log(LogWarning, "JsonRpcConnection",
+                   "We received a JSON-RPC response message. This should never happen because we're only ever sending notifications.");
 
                return;
        }
@@ -306,11 +287,6 @@ Value SetLogPositionHandler(const MessageOrigin::Ptr& origin, const Dictionary::
        return Empty;
 }
 
-bool ApiCallbackInfo::IsExpired(void) const
-{
-       return Timestamp < Utility::GetTime() - 300;
-}
-
 void JsonRpcConnection::CheckLiveness(void)
 {
        if (m_Seen < Utility::GetTime() - 60 && (!m_Endpoint || !m_Endpoint->GetSyncing())) {
@@ -318,18 +294,6 @@ void JsonRpcConnection::CheckLiveness(void)
                    <<  "No messages for identity '" << m_Identity << "' have been received in the last 60 seconds.";
                Disconnect();
        }
-
-       {
-               boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
-
-               for (auto it = m_ApiCallbacks.begin(), last = m_ApiCallbacks.end(); it != last; ) {
-                       if (it->second.IsExpired()) {
-                               it = m_ApiCallbacks.erase(it);
-                       } else {
-                               ++it;
-                       }
-               }
-       }
 }
 
 void JsonRpcConnection::TimeoutTimerHandler(void)
@@ -379,14 +343,3 @@ double JsonRpcConnection::GetWorkQueueRate(void)
        return rate / count;
 }
 
-void JsonRpcConnection::RegisterCallback(const String& id, const boost::function<void (const Dictionary::Ptr&)>& callback)
-{
-       ApiCallbackInfo aci;
-       aci.Timestamp = Utility::GetTime();
-       aci.Callback = callback;
-
-       {
-               boost::mutex::scoped_lock lock(m_ApiCallbacksMutex);
-               m_ApiCallbacks[id] = aci;
-       }
-}
index 7a40f5f1572941385dd70b5e39ccd97c5745ce1d..e62799c1eca69fafd104b369d7e234ca38950584 100644 (file)
@@ -43,14 +43,6 @@ enum ClientType
 
 class MessageOrigin;
 
-struct ApiCallbackInfo
-{
-       double Timestamp;
-       boost::function<void (const Dictionary::Ptr&)> Callback;
-
-       bool IsExpired(void) const;
-};
-
 /**
  * An API client connection.
  *
@@ -97,8 +89,6 @@ private:
        double m_NextHeartbeat;
        double m_HeartbeatTimeout;
        boost::mutex m_DataHandlerMutex;
-       std::map<String, ApiCallbackInfo> m_ApiCallbacks;
-       boost::mutex m_ApiCallbacksMutex;
 
        StreamReadContext m_Context;
 
@@ -111,8 +101,6 @@ private:
        static void TimeoutTimerHandler(void);
        void CheckLiveness(void);
 
-       void RegisterCallback(const String& id, const boost::function<void (const Dictionary::Ptr&)>& callback);
-
        void CertificateRequestResponseHandler(const Dictionary::Ptr& message);
 };