mirror of https://github.com/Icinga/icinga2.git
Added assert()s for some common thread-safety problems.
This commit is contained in:
parent
f2979eb08b
commit
60c4dce4dd
|
@ -134,6 +134,8 @@ Component::Ptr Application::LoadComponent(const string& path,
|
||||||
Component::Ptr component;
|
Component::Ptr component;
|
||||||
Component *(*pCreateComponent)();
|
Component *(*pCreateComponent)();
|
||||||
|
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
Logger::Write(LogInformation, "base", "Loading component '" + path + "'");
|
Logger::Write(LogInformation, "base", "Loading component '" + path + "'");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -113,6 +113,8 @@ time_t ConfigObject::GetCommitTimestamp(void) const
|
||||||
|
|
||||||
void ConfigObject::Commit(void)
|
void ConfigObject::Commit(void)
|
||||||
{
|
{
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
|
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
|
||||||
ConfigObject::Ptr self = GetSelf();
|
ConfigObject::Ptr self = GetSelf();
|
||||||
assert(!dobj || dobj == self);
|
assert(!dobj || dobj == self);
|
||||||
|
@ -125,6 +127,8 @@ void ConfigObject::Commit(void)
|
||||||
|
|
||||||
void ConfigObject::Unregister(void)
|
void ConfigObject::Unregister(void)
|
||||||
{
|
{
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
ConfigObject::Ptr self = GetSelf();
|
ConfigObject::Ptr self = GetSelf();
|
||||||
m_Container->RemoveObject(self);
|
m_Container->RemoveObject(self);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ void Logger::Write(LogSeverity severity, const string& facility,
|
||||||
*/
|
*/
|
||||||
void Logger::RegisterLogger(const Logger::Ptr& logger)
|
void Logger::RegisterLogger(const Logger::Ptr& logger)
|
||||||
{
|
{
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
m_Loggers.push_back(logger);
|
m_Loggers.push_back(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,10 @@ Socket::Socket(void)
|
||||||
* Destructor for the Socket class.
|
* Destructor for the Socket class.
|
||||||
*/
|
*/
|
||||||
Socket::~Socket(void)
|
Socket::~Socket(void)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
mutex::scoped_lock lock(m_Mutex);
|
mutex::scoped_lock lock(m_Mutex);
|
||||||
|
|
||||||
CloseInternal(true);
|
CloseInternal(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Socket::Start(void)
|
void Socket::Start(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,6 +136,8 @@ long Timer::GetInterval(void) const
|
||||||
*/
|
*/
|
||||||
void Timer::Start(void)
|
void Timer::Start(void)
|
||||||
{
|
{
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
Timers.push_back(GetSelf());
|
Timers.push_back(GetSelf());
|
||||||
|
@ -148,6 +150,8 @@ void Timer::Start(void)
|
||||||
*/
|
*/
|
||||||
void Timer::Stop(void)
|
void Timer::Stop(void)
|
||||||
{
|
{
|
||||||
|
assert(Application::IsMainThread());
|
||||||
|
|
||||||
Timers.remove_if(WeakPtrEqual<Timer>(this));
|
Timers.remove_if(WeakPtrEqual<Timer>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue