mirror of https://github.com/Icinga/icinga2.git
Make ApiListener::m_ConfigSyncStageLock a SpinLock
This commit is contained in:
parent
4af450141b
commit
a083635de4
|
@ -20,7 +20,7 @@ using namespace icinga;
|
||||||
|
|
||||||
REGISTER_APIFUNCTION(Update, config, &ApiListener::ConfigUpdateHandler);
|
REGISTER_APIFUNCTION(Update, config, &ApiListener::ConfigUpdateHandler);
|
||||||
|
|
||||||
boost::mutex ApiListener::m_ConfigSyncStageLock;
|
SpinLock ApiListener::m_ConfigSyncStageLock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entrypoint for updating all authoritative configs from /etc/zones.d, packages, etc.
|
* Entrypoint for updating all authoritative configs from /etc/zones.d, packages, etc.
|
||||||
|
@ -321,7 +321,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic
|
||||||
/* Only one transaction is allowed, concurrent message handlers need to wait.
|
/* Only one transaction is allowed, concurrent message handlers need to wait.
|
||||||
* This affects two parent endpoints sending the config in the same moment.
|
* This affects two parent endpoints sending the config in the same moment.
|
||||||
*/
|
*/
|
||||||
auto lock (Shared<boost::mutex::scoped_lock>::Make(m_ConfigSyncStageLock));
|
auto lock (Shared<std::unique_lock<SpinLock>>::Make(m_ConfigSyncStageLock));
|
||||||
|
|
||||||
String apiZonesStageDir = GetApiZonesStageDir();
|
String apiZonesStageDir = GetApiZonesStageDir();
|
||||||
String fromEndpointName = origin->FromClient->GetEndpoint()->GetName();
|
String fromEndpointName = origin->FromClient->GetEndpoint()->GetName();
|
||||||
|
@ -618,7 +618,7 @@ void ApiListener::TryActivateZonesStageCallback(const ProcessResult& pr,
|
||||||
*
|
*
|
||||||
* @param relativePaths Required for later file operations in the callback. Provides the zone name plus path in a list.
|
* @param relativePaths Required for later file operations in the callback. Provides the zone name plus path in a list.
|
||||||
*/
|
*/
|
||||||
void ApiListener::AsyncTryActivateZonesStage(const std::vector<String>& relativePaths, const Shared<boost::mutex::scoped_lock>::Ptr& lock)
|
void ApiListener::AsyncTryActivateZonesStage(const std::vector<String>& relativePaths, const Shared<std::unique_lock<SpinLock>>::Ptr& lock)
|
||||||
{
|
{
|
||||||
VERIFY(Application::GetArgC() >= 1);
|
VERIFY(Application::GetArgC() >= 1);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "base/configobject.hpp"
|
#include "base/configobject.hpp"
|
||||||
#include "base/process.hpp"
|
#include "base/process.hpp"
|
||||||
#include "base/shared.hpp"
|
#include "base/shared.hpp"
|
||||||
|
#include "base/spinlock.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
#include "base/workqueue.hpp"
|
#include "base/workqueue.hpp"
|
||||||
#include "base/tcpsocket.hpp"
|
#include "base/tcpsocket.hpp"
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
|
#include <mutex>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -186,7 +188,7 @@ private:
|
||||||
void RemoveStatusFile();
|
void RemoveStatusFile();
|
||||||
|
|
||||||
/* filesync */
|
/* filesync */
|
||||||
static boost::mutex m_ConfigSyncStageLock;
|
static SpinLock m_ConfigSyncStageLock;
|
||||||
|
|
||||||
void SyncLocalZoneDirs() const;
|
void SyncLocalZoneDirs() const;
|
||||||
void SyncLocalZoneDir(const Zone::Ptr& zone) const;
|
void SyncLocalZoneDir(const Zone::Ptr& zone) const;
|
||||||
|
@ -200,7 +202,7 @@ private:
|
||||||
|
|
||||||
static void TryActivateZonesStageCallback(const ProcessResult& pr,
|
static void TryActivateZonesStageCallback(const ProcessResult& pr,
|
||||||
const std::vector<String>& relativePaths);
|
const std::vector<String>& relativePaths);
|
||||||
static void AsyncTryActivateZonesStage(const std::vector<String>& relativePaths, const Shared<boost::mutex::scoped_lock>::Ptr& lock);
|
static void AsyncTryActivateZonesStage(const std::vector<String>& relativePaths, const Shared<std::unique_lock<SpinLock>>::Ptr& lock);
|
||||||
|
|
||||||
static String GetChecksum(const String& content);
|
static String GetChecksum(const String& content);
|
||||||
static bool CheckConfigChange(const ConfigDirInformation& oldConfig, const ConfigDirInformation& newConfig);
|
static bool CheckConfigChange(const ConfigDirInformation& oldConfig, const ConfigDirInformation& newConfig);
|
||||||
|
|
Loading…
Reference in New Issue