function.cpp function-script.cpp functionwrapper.cpp scriptglobal.cpp
scriptutils.cpp serializer.cpp socket.cpp socketevents.cpp stacktrace.cpp
statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp string-script.cpp
- sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp
+ sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp threadpool.cpp timer.cpp
tlsstream.cpp tlsutility.cpp type.cpp typetype-script.cpp unixsocket.cpp utility.cpp value.cpp
value-operators.cpp workqueue.cpp
)
*/
void Application::UpdatePidFile(const String& filename, pid_t pid)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
if (m_PidFile != NULL)
*/
void Application::ClosePidFile(bool unlink)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
if (m_PidFile != NULL)
*/
Value Array::Get(unsigned int index) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
return m_Data.at(index);
*/
void Array::Set(unsigned int index, const Value& value)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.at(index) = value;
*/
void Array::Add(const Value& value)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.push_back(value);
*/
size_t Array::GetLength(void) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
return m_Data.size();
*/
bool Array::Contains(const Value& value) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
return (std::find(m_Data.begin(), m_Data.end(), value) != m_Data.end());
*/
void Array::Insert(unsigned int index, const Value& value)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
ASSERT(index <= m_Data.size());
*/
void Array::Remove(unsigned int index)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.erase(m_Data.begin() + index);
void Array::Resize(size_t new_size)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.resize(new_size);
void Array::Clear(void)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.clear();
void Array::Reserve(size_t new_size)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.reserve(new_size);
void Array::CopyTo(const Array::Ptr& dest) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
ObjectLock xlock(dest);
{
ObjectImpl<ConfigObject>::Start(runtimeCreated);
- ASSERT(!OwnsLock());
ObjectLock olock(this);
SetStartCalled(true);
{
CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
- ASSERT(!OwnsLock());
-
Start(runtimeCreated);
ASSERT(GetStartCalled());
{
ObjectImpl<ConfigObject>::Stop(runtimeRemoved);
- ASSERT(!OwnsLock());
ObjectLock olock(this);
SetStopCalled(true);
{
CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
- ASSERT(!OwnsLock());
-
SetAuthority(false);
{
ConfigType::ConfigType(const String& name)
: m_Name(name)
-{
- InflateMutex();
-}
+{ }
ConfigType::Ptr ConfigType::GetByName(const String& name)
{
*/
Value Dictionary::Get(const String& key) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
std::map<String, Value>::const_iterator it = m_Data.find(key);
*/
bool Dictionary::Get(const String& key, Value *result) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
std::map<String, Value>::const_iterator it = m_Data.find(key);
*/
void Dictionary::Set(const String& key, const Value& value)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data[key] = value;
*/
size_t Dictionary::GetLength(void) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
return m_Data.size();
*/
bool Dictionary::Contains(const String& key) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
return (m_Data.find(key) != m_Data.end());
*/
void Dictionary::Remove(const String& key)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
Dictionary::Iterator it;
*/
void Dictionary::Clear(void)
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
m_Data.clear();
void Dictionary::CopyTo(const Dictionary::Ptr& dest) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
BOOST_FOREACH(const Dictionary::Pair& kv, m_Data) {
*/
std::vector<String> Dictionary::GetKeys(void) const
{
- ASSERT(!OwnsLock());
ObjectLock olock(this);
std::vector<String> keys;
}
#endif /* I2_DEBUG */
-void Object::InflateMutex(void)
-{
- m_Mutex.Inflate();
-}
-
void Object::SetField(int id, const Value&, bool, const Value&)
{
if (id == 0)
#include "base/i2-base.hpp"
#include "base/debug.hpp"
-#include "base/thinmutex.hpp"
-
-#ifndef I2_DEBUG
-#include <boost/thread/mutex.hpp>
-#else /* I2_DEBUG */
#include <boost/thread/recursive_mutex.hpp>
-#endif /* I2_DEBUG */
-
#include <boost/thread/condition_variable.hpp>
-
#include <boost/smart_ptr/intrusive_ptr.hpp>
using boost::intrusive_ptr;
bool OwnsLock(void) const;
#endif /* I2_DEBUG */
- void InflateMutex(void);
-
static Object::Ptr GetPrototype(void);
virtual Object::Ptr Clone(void) const;
Object& operator=(const Object& rhs);
uintptr_t m_References;
- mutable ThinMutex m_Mutex;
+ mutable boost::recursive_mutex m_Mutex;
#ifdef I2_DEBUG
# ifndef _WIN32
inline void Lock(void)
{
ASSERT(!m_Locked && m_Object != NULL);
- ASSERT(!m_Object->OwnsLock());
- m_Object->m_Mutex.Lock();
+ m_Object->m_Mutex.lock();
m_Locked = true;
#ifdef I2_DEBUG
#endif /* I2_DEBUG */
if (m_Locked) {
- m_Object->m_Mutex.Unlock();
+ m_Object->m_Mutex.unlock();
m_Locked = false;
}
}
+++ /dev/null
-/******************************************************************************
- * Icinga 2 *
- * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software Foundation *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
- ******************************************************************************/
-
-#include "base/thinmutex.hpp"
-#include "base/timer.hpp"
-#include "base/convert.hpp"
-#include "base/logger.hpp"
-
-using namespace icinga;
-
-/**
- * Locks the mutex and inflates the lock.
- */
-void ThinMutex::LockSlowPath(void)
-{
- unsigned int it = 0;
-
-#ifdef _WIN32
-# ifdef _WIN64
- while (InterlockedCompareExchange64(&m_Data, THINLOCK_LOCKED, THINLOCK_UNLOCKED) != THINLOCK_UNLOCKED) {
-# else /* _WIN64 */
- while (InterlockedCompareExchange(&m_Data, THINLOCK_LOCKED, THINLOCK_UNLOCKED) != THINLOCK_UNLOCKED) {
-# endif /* _WIN64 */
-#else /* _WIN32 */
- while (!__sync_bool_compare_and_swap(&m_Data, THINLOCK_UNLOCKED, THINLOCK_LOCKED)) {
-#endif /* _WIN32 */
- if (m_Data > THINLOCK_LOCKED) {
- boost::mutex *mtx = reinterpret_cast<boost::mutex *>(m_Data);
- mtx->lock();
-
- return;
- }
-
- Spin(it);
- it++;
- }
-
- boost::mutex *mtx = new boost::mutex();
- mtx->lock();
-#ifdef _WIN32
-# ifdef _WIN64
- InterlockedCompareExchange64(&m_Data, reinterpret_cast<LONGLONG>(mtx), THINLOCK_LOCKED);
-# else /* _WIN64 */
- InterlockedCompareExchange(&m_Data, reinterpret_cast<LONG>(mtx), THINLOCK_LOCKED);
-# endif /* _WIN64 */
-#else /* _WIN32 */
- __sync_bool_compare_and_swap(&m_Data, THINLOCK_LOCKED, reinterpret_cast<uintptr_t>(mtx));
-#endif /* _WIN32 */
-}
-
+++ /dev/null
-/******************************************************************************
- * Icinga 2 *
- * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software Foundation *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
- ******************************************************************************/
-
-#ifndef THINMUTEX_H
-#define THINMUTEX_H
-
-#include "base/i2-base.hpp"
-#include <boost/thread/mutex.hpp>
-#ifndef _WIN32
-#include <sched.h>
-#endif /* _WIN32 */
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310 && (defined(_M_IX86) || defined(_M_X64))
-extern "C" void _mm_pause();
-#pragma intrinsic(_mm_pause)
-#define SPIN_PAUSE() _mm_pause()
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-#define SPIN_PAUSE() __asm__ __volatile__("rep; nop" : : : "memory")
-#endif
-
-#define THINLOCK_UNLOCKED 0
-#define THINLOCK_LOCKED 1
-
-namespace icinga {
-
-class I2_BASE_API ThinMutex
-{
-public:
- inline ThinMutex(void)
- : m_Data(THINLOCK_UNLOCKED)
- { }
-
- inline ~ThinMutex(void)
- {
- if (m_Data > THINLOCK_LOCKED)
- delete reinterpret_cast<boost::mutex *>(m_Data);
- }
-
- inline void Lock(void)
- {
-#ifdef _WIN32
-# ifdef _WIN64
- if (InterlockedCompareExchange64(&m_Data, THINLOCK_LOCKED, THINLOCK_UNLOCKED) != THINLOCK_UNLOCKED) {
-# else /* _WIN64 */
- if (InterlockedCompareExchange(&m_Data, THINLOCK_LOCKED, THINLOCK_UNLOCKED) != THINLOCK_UNLOCKED) {
-# endif /* _WIN64 */
-#else /* _WIN32 */
- if (!__sync_bool_compare_and_swap(&m_Data, THINLOCK_UNLOCKED, THINLOCK_LOCKED)) {
-#endif /* _WIN32 */
- LockSlowPath();
- }
- }
-
- inline void Unlock(void)
- {
-#ifdef _WIN32
-# ifdef _WIN64
- if (InterlockedCompareExchange64(&m_Data, THINLOCK_UNLOCKED, THINLOCK_LOCKED) != THINLOCK_LOCKED) {
-# else /* _WIN64 */
- if (InterlockedCompareExchange(&m_Data, THINLOCK_UNLOCKED, THINLOCK_LOCKED) != THINLOCK_LOCKED) {
-# endif /* _WIN64 */
-#else /* _WIN32 */
- if (!__sync_bool_compare_and_swap(&m_Data, THINLOCK_LOCKED, THINLOCK_UNLOCKED)) {
-#endif /* _WIN32 */
- boost::mutex *mtx = reinterpret_cast<boost::mutex *>(m_Data);
- mtx->unlock();
- }
- }
-
- inline void Inflate(void)
- {
- LockSlowPath();
- Unlock();
- }
-
-private:
- inline void Spin(unsigned int it)
- {
- if (it < 8) {
- /* Do nothing. */
- }
-#ifdef SPIN_PAUSE
- else if (it < 16) {
- SPIN_PAUSE();
- }
-#endif /* SPIN_PAUSE */
- else {
-#ifdef _WIN32
- Sleep(0);
-#else /* _WIN32 */
- sched_yield();
-#endif /* _WIN32 */
- }
- }
-
-private:
-#ifdef _WIN32
-# ifdef _WIN64
- LONGLONG m_Data;
-# else /* _WIN64 */
- LONG m_Data;
-# endif /* _WIN64 */
-#else /* _WIN32 */
- uintptr_t m_Data;
-#endif /* _WIN32 */
-
- void LockSlowPath(void);
-};
-
-}
-
-#endif /* THINMUTEX_H */
*/
void Timer::Call(void)
{
- ASSERT(!OwnsLock());
-
try {
OnTimerExpired(Timer::Ptr(this));
} catch (...) {
*/
void Timer::SetInterval(double interval)
{
- ASSERT(!OwnsLock());
-
boost::mutex::scoped_lock lock(l_TimerMutex);
m_Interval = interval;
}
*/
double Timer::GetInterval(void) const
{
- ASSERT(!OwnsLock());
-
boost::mutex::scoped_lock lock(l_TimerMutex);
return m_Interval;
}
*/
void Timer::Start(void)
{
- ASSERT(!OwnsLock());
-
{
boost::mutex::scoped_lock lock(l_TimerMutex);
m_Started = true;
*/
void Timer::Stop(bool wait)
{
- ASSERT(!OwnsLock());
-
if (l_StopTimerThread)
return;
*/
void Timer::InternalReschedule(bool completed, double next)
{
- ASSERT(!OwnsLock());
-
boost::mutex::scoped_lock lock(l_TimerMutex);
if (completed)
*/
double Timer::GetNext(void) const
{
- ASSERT(!OwnsLock());
-
boost::mutex::scoped_lock lock(l_TimerMutex);
return m_Next;
}
*/
ConfigObject::Ptr ConfigItem::Commit(bool discard)
{
- ASSERT(!OwnsLock());
-
#ifdef I2_DEBUG
Log(LogDebug, "ConfigItem")
<< "Commit called for ConfigItem Type=" << GetType() << ", Name=" << GetName();
DbObject::Ptr DbType::GetOrCreateObjectByName(const String& name1, const String& name2)
{
- ASSERT(!OwnsLock());
-
ObjectLock olock(this);
DbType::ObjectMap::const_iterator it = m_Objects.find(std::make_pair(name1, name2));
bool reachable = IsReachable();
bool notification_reachable = IsReachable(DependencyNotification);
- ASSERT(!OwnsLock());
ObjectLock olock(this);
CheckResult::Ptr old_cr = GetLastCheckResult();
GetCheckCommand()->Execute(this, cr, resolvedMacros, true);
}
-void Checkable::ExecuteCheck()
+void Checkable::ExecuteCheck(void)
{
CONTEXT("Executing check for object '" + GetName() + "'");
- ASSERT(!OwnsLock());
-
UpdateNextCheck();
bool reachable = IsReachable();
void IcingaApplication::OnShutdown(void)
{
- ASSERT(!OwnsLock());
-
{
ObjectLock olock(this);
l_RetentionTimer->Stop();
void Notification::BeginExecuteNotification(NotificationType type, const CheckResult::Ptr& cr, bool force, const String& author, const String& text)
{
- ASSERT(!OwnsLock());
-
Log(LogNotice, "Notification")
<< "Attempting to send notifications for notification object '" << GetName() << "'.";
bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force)
{
- ASSERT(!OwnsLock());
-
if (!force) {
TimePeriod::Ptr tp = user->GetPeriod();
void Notification::ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author, const String& text)
{
- ASSERT(!OwnsLock());
-
try {
NotificationCommand::Ptr command = GetCommand();