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 *(*pCreateComponent)();
|
||||
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
Logger::Write(LogInformation, "base", "Loading component '" + path + "'");
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -113,6 +113,8 @@ time_t ConfigObject::GetCommitTimestamp(void) const
|
|||
|
||||
void ConfigObject::Commit(void)
|
||||
{
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
|
||||
ConfigObject::Ptr self = GetSelf();
|
||||
assert(!dobj || dobj == self);
|
||||
|
@ -125,6 +127,8 @@ void ConfigObject::Commit(void)
|
|||
|
||||
void ConfigObject::Unregister(void)
|
||||
{
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
ConfigObject::Ptr self = GetSelf();
|
||||
m_Container->RemoveObject(self);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ void Logger::Write(LogSeverity severity, const string& facility,
|
|||
*/
|
||||
void Logger::RegisterLogger(const Logger::Ptr& logger)
|
||||
{
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
m_Loggers.push_back(logger);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,8 @@ Socket::Socket(void)
|
|||
*/
|
||||
Socket::~Socket(void)
|
||||
{
|
||||
{
|
||||
mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
CloseInternal(true);
|
||||
}
|
||||
mutex::scoped_lock lock(m_Mutex);
|
||||
CloseInternal(true);
|
||||
}
|
||||
|
||||
void Socket::Start(void)
|
||||
|
|
|
@ -136,6 +136,8 @@ long Timer::GetInterval(void) const
|
|||
*/
|
||||
void Timer::Start(void)
|
||||
{
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
Stop();
|
||||
|
||||
Timers.push_back(GetSelf());
|
||||
|
@ -148,6 +150,8 @@ void Timer::Start(void)
|
|||
*/
|
||||
void Timer::Stop(void)
|
||||
{
|
||||
assert(Application::IsMainThread());
|
||||
|
||||
Timers.remove_if(WeakPtrEqual<Timer>(this));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue