From af1edb7d94d450e23a88fba741fd1523e30f7c2d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 29 Mar 2012 20:23:13 +0200 Subject: [PATCH] Fixed crash bug in Timer::StopAllTimers Fixed compilation error with gcc (in connectionmanager.cpp) Use unformatted JSON strings in release builds --- base/timer.cpp | 3 ++- jsonrpc/connectionmanager.cpp | 2 -- jsonrpc/netstring.cpp | 12 ++++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/base/timer.cpp b/base/timer.cpp index 885bb0693..6ff6e191f 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -62,7 +62,8 @@ void Timer::CallExpiredTimers(void) void Timer::StopAllTimers(void) { for (list::iterator i = Timers.begin(); i != Timers.end(); ) { - Timer::RefType timer = Timer::RefType(*i); + Timer::RefType timer = i->lock(); + i++; if (timer == NULL) diff --git a/jsonrpc/connectionmanager.cpp b/jsonrpc/connectionmanager.cpp index 98787f35d..3d23299c9 100644 --- a/jsonrpc/connectionmanager.cpp +++ b/jsonrpc/connectionmanager.cpp @@ -1,8 +1,6 @@ #include "i2-jsonrpc.h" using namespace icinga; -using std::map; -using std::function; void ConnectionManager::BindServer(JsonRpcServer::RefType server) { diff --git a/jsonrpc/netstring.cpp b/jsonrpc/netstring.cpp index 7b0885041..05e6227ce 100644 --- a/jsonrpc/netstring.cpp +++ b/jsonrpc/netstring.cpp @@ -59,8 +59,16 @@ cJSON *Netstring::ReadJSONFromFIFO(FIFO::RefType fifo) void Netstring::WriteJSONToFIFO(FIFO::RefType fifo, cJSON *object) { - char *json = cJSON_Print(object); - size_t len = strlen(json); + char *json; + size_t len; + +#ifdef _DEBUG + json = cJSON_Print(object); +#else /* _DEBUG */ + json = cJSON_PrintUnformatted(object); +#endif /* _DEBUG */ + + len = strlen(json); char strLength[50]; sprintf(strLength, "%lu", (unsigned long)len); -- 2.50.1