Fixed crash bug in Timer::StopAllTimers

Fixed compilation error with gcc (in connectionmanager.cpp)
Use unformatted JSON strings in release builds
This commit is contained in:
Gunnar Beutner 2012-03-29 20:23:13 +02:00
parent 1ebda64e75
commit af1edb7d94
3 changed files with 12 additions and 5 deletions

View File

@ -62,7 +62,8 @@ void Timer::CallExpiredTimers(void)
void Timer::StopAllTimers(void) void Timer::StopAllTimers(void)
{ {
for (list<Timer::WeakRefType>::iterator i = Timers.begin(); i != Timers.end(); ) { for (list<Timer::WeakRefType>::iterator i = Timers.begin(); i != Timers.end(); ) {
Timer::RefType timer = Timer::RefType(*i); Timer::RefType timer = i->lock();
i++; i++;
if (timer == NULL) if (timer == NULL)

View File

@ -1,8 +1,6 @@
#include "i2-jsonrpc.h" #include "i2-jsonrpc.h"
using namespace icinga; using namespace icinga;
using std::map;
using std::function;
void ConnectionManager::BindServer(JsonRpcServer::RefType server) void ConnectionManager::BindServer(JsonRpcServer::RefType server)
{ {

View File

@ -59,8 +59,16 @@ cJSON *Netstring::ReadJSONFromFIFO(FIFO::RefType fifo)
void Netstring::WriteJSONToFIFO(FIFO::RefType fifo, cJSON *object) void Netstring::WriteJSONToFIFO(FIFO::RefType fifo, cJSON *object)
{ {
char *json = cJSON_Print(object); char *json;
size_t len = strlen(json); size_t len;
#ifdef _DEBUG
json = cJSON_Print(object);
#else /* _DEBUG */
json = cJSON_PrintUnformatted(object);
#endif /* _DEBUG */
len = strlen(json);
char strLength[50]; char strLength[50];
sprintf(strLength, "%lu", (unsigned long)len); sprintf(strLength, "%lu", (unsigned long)len);