mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
Move inline functions to their .cpp files
This commit is contained in:
parent
91c256261a
commit
f05459b40c
@ -406,3 +406,34 @@ Dictionary::Ptr ValidationError::GetDebugHint() const
|
|||||||
return m_DebugHint;
|
return m_DebugHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string icinga::to_string(const StackTraceErrorInfo&)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string icinga::to_string(const errinfo_win32_error& e)
|
||||||
|
{
|
||||||
|
return "[errinfo_win32_error] = " + Utility::FormatErrorNumber(e.value()) + "\n";
|
||||||
|
}
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
std::string icinga::to_string(const errinfo_getaddrinfo_error& e)
|
||||||
|
{
|
||||||
|
String msg;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
msg = gai_strerrorA(e.value());
|
||||||
|
#else /* _WIN32 */
|
||||||
|
msg = gai_strerror(e.value());
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
return "[errinfo_getaddrinfo_error] = " + String(msg) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string icinga::to_string(const ContextTraceErrorInfo& e)
|
||||||
|
{
|
||||||
|
std::ostringstream msgbuf;
|
||||||
|
msgbuf << "[Context] = " << e.value();
|
||||||
|
return msgbuf.str();
|
||||||
|
}
|
||||||
|
@ -106,19 +106,11 @@ void RethrowUncaughtException();
|
|||||||
|
|
||||||
typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
|
typedef boost::error_info<StackTrace, StackTrace> StackTraceErrorInfo;
|
||||||
|
|
||||||
inline std::string to_string(const StackTraceErrorInfo&)
|
std::string to_string(const StackTraceErrorInfo&);
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef boost::error_info<ContextTrace, ContextTrace> ContextTraceErrorInfo;
|
typedef boost::error_info<ContextTrace, ContextTrace> ContextTraceErrorInfo;
|
||||||
|
|
||||||
inline std::string to_string(const ContextTraceErrorInfo& e)
|
std::string to_string(const ContextTraceErrorInfo& e);
|
||||||
{
|
|
||||||
std::ostringstream msgbuf;
|
|
||||||
msgbuf << "[Context] = " << e.value();
|
|
||||||
return msgbuf.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = nullptr, ContextTrace *context = nullptr);
|
String DiagnosticInformation(const std::exception& ex, bool verbose = true, StackTrace *stack = nullptr, ContextTrace *context = nullptr);
|
||||||
String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = true);
|
String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = true);
|
||||||
@ -139,27 +131,13 @@ class win32_error : virtual public std::exception, virtual public boost::excepti
|
|||||||
struct errinfo_win32_error_;
|
struct errinfo_win32_error_;
|
||||||
typedef boost::error_info<struct errinfo_win32_error_, int> errinfo_win32_error;
|
typedef boost::error_info<struct errinfo_win32_error_, int> errinfo_win32_error;
|
||||||
|
|
||||||
inline std::string to_string(const errinfo_win32_error& e)
|
std::string to_string(const errinfo_win32_error& e);
|
||||||
{
|
|
||||||
return "[errinfo_win32_error] = " + Utility::FormatErrorNumber(e.value()) + "\n";
|
|
||||||
}
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
struct errinfo_getaddrinfo_error_;
|
struct errinfo_getaddrinfo_error_;
|
||||||
typedef boost::error_info<struct errinfo_getaddrinfo_error_, int> errinfo_getaddrinfo_error;
|
typedef boost::error_info<struct errinfo_getaddrinfo_error_, int> errinfo_getaddrinfo_error;
|
||||||
|
|
||||||
inline std::string to_string(const errinfo_getaddrinfo_error& e)
|
std::string to_string(const errinfo_getaddrinfo_error& e);
|
||||||
{
|
|
||||||
String msg;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
msg = gai_strerrorA(e.value());
|
|
||||||
#else /* _WIN32 */
|
|
||||||
msg = gai_strerror(e.value());
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
return "[errinfo_getaddrinfo_error] = " + String(msg) + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
struct errinfo_message_;
|
struct errinfo_message_;
|
||||||
typedef boost::error_info<struct errinfo_message_, std::string> errinfo_message;
|
typedef boost::error_info<struct errinfo_message_, std::string> errinfo_message;
|
||||||
|
@ -252,3 +252,35 @@ INITIALIZE_ONCE([]() {
|
|||||||
});
|
});
|
||||||
#endif /* I2_LEAK_DEBUG */
|
#endif /* I2_LEAK_DEBUG */
|
||||||
|
|
||||||
|
void icinga::intrusive_ptr_add_ref(Object *object)
|
||||||
|
{
|
||||||
|
#ifdef I2_LEAK_DEBUG
|
||||||
|
if (object->m_References == 0)
|
||||||
|
TypeAddObject(object);
|
||||||
|
#endif /* I2_LEAK_DEBUG */
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
InterlockedIncrement(&object->m_References);
|
||||||
|
#else /* _WIN32 */
|
||||||
|
__sync_add_and_fetch(&object->m_References, 1);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
}
|
||||||
|
|
||||||
|
void icinga::intrusive_ptr_release(Object *object)
|
||||||
|
{
|
||||||
|
uintptr_t refs;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
refs = InterlockedDecrement(&object->m_References);
|
||||||
|
#else /* _WIN32 */
|
||||||
|
refs = __sync_sub_and_fetch(&object->m_References, 1);
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
if (unlikely(refs == 0)) {
|
||||||
|
#ifdef I2_LEAK_DEBUG
|
||||||
|
TypeRemoveObject(object);
|
||||||
|
#endif /* I2_LEAK_DEBUG */
|
||||||
|
|
||||||
|
delete object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -164,38 +164,8 @@ Value GetPrototypeField(const Value& context, const String& field, bool not_foun
|
|||||||
void TypeAddObject(Object *object);
|
void TypeAddObject(Object *object);
|
||||||
void TypeRemoveObject(Object *object);
|
void TypeRemoveObject(Object *object);
|
||||||
|
|
||||||
inline void intrusive_ptr_add_ref(Object *object)
|
void intrusive_ptr_add_ref(Object *object);
|
||||||
{
|
void intrusive_ptr_release(Object *object);
|
||||||
#ifdef I2_LEAK_DEBUG
|
|
||||||
if (object->m_References == 0)
|
|
||||||
TypeAddObject(object);
|
|
||||||
#endif /* I2_LEAK_DEBUG */
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
InterlockedIncrement(&object->m_References);
|
|
||||||
#else /* _WIN32 */
|
|
||||||
__sync_add_and_fetch(&object->m_References, 1);
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void intrusive_ptr_release(Object *object)
|
|
||||||
{
|
|
||||||
uintptr_t refs;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
refs = InterlockedDecrement(&object->m_References);
|
|
||||||
#else /* _WIN32 */
|
|
||||||
refs = __sync_sub_and_fetch(&object->m_References, 1);
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
if (unlikely(refs == 0)) {
|
|
||||||
#ifdef I2_LEAK_DEBUG
|
|
||||||
TypeRemoveObject(object);
|
|
||||||
#endif /* I2_LEAK_DEBUG */
|
|
||||||
|
|
||||||
delete object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ObjectImpl
|
class ObjectImpl
|
||||||
|
@ -782,4 +782,19 @@ bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::sh
|
|||||||
return rc == 1;
|
return rc == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_string(const errinfo_openssl_error& e)
|
||||||
|
{
|
||||||
|
std::ostringstream tmp;
|
||||||
|
int code = e.value();
|
||||||
|
char errbuf[120];
|
||||||
|
|
||||||
|
const char *message = ERR_error_string(code, errbuf);
|
||||||
|
|
||||||
|
if (!message)
|
||||||
|
message = "Unknown error.";
|
||||||
|
|
||||||
|
tmp << code << ", \"" << message << "\"";
|
||||||
|
return "[errinfo_openssl_error]" + tmp.str() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,20 +61,7 @@ class openssl_error : virtual public std::exception, virtual public boost::excep
|
|||||||
struct errinfo_openssl_error_;
|
struct errinfo_openssl_error_;
|
||||||
typedef boost::error_info<struct errinfo_openssl_error_, unsigned long> errinfo_openssl_error;
|
typedef boost::error_info<struct errinfo_openssl_error_, unsigned long> errinfo_openssl_error;
|
||||||
|
|
||||||
inline std::string to_string(const errinfo_openssl_error& e)
|
std::string to_string(const errinfo_openssl_error& e);
|
||||||
{
|
|
||||||
std::ostringstream tmp;
|
|
||||||
int code = e.value();
|
|
||||||
char errbuf[120];
|
|
||||||
|
|
||||||
const char *message = ERR_error_string(code, errbuf);
|
|
||||||
|
|
||||||
if (!message)
|
|
||||||
message = "Unknown error.";
|
|
||||||
|
|
||||||
tmp << code << ", \"" << message << "\"";
|
|
||||||
return "[errinfo_openssl_error]" + tmp.str() + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,3 +299,18 @@ size_t WorkQueue::GetTaskCount(RingBuffer::SizeType span)
|
|||||||
boost::mutex::scoped_lock lock(m_StatsMutex);
|
boost::mutex::scoped_lock lock(m_StatsMutex);
|
||||||
return m_TaskStats.UpdateAndGetValues(Utility::GetTime(), span);
|
return m_TaskStats.UpdateAndGetValues(Utility::GetTime(), span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool icinga::operator<(const Task& a, const Task& b)
|
||||||
|
{
|
||||||
|
if (a.Priority < b.Priority)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (a.Priority == b.Priority) {
|
||||||
|
if (a.ID > b.ID)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -54,20 +54,7 @@ struct Task
|
|||||||
int ID{-1};
|
int ID{-1};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator<(const Task& a, const Task& b)
|
bool operator<(const Task& a, const Task& b);
|
||||||
{
|
|
||||||
if (a.Priority < b.Priority)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (a.Priority == b.Priority) {
|
|
||||||
if (a.ID > b.ID)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A workqueue.
|
* A workqueue.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user