From 0e2417dfd7616a50490b12ca2c3c71272dc53c3d Mon Sep 17 00:00:00 2001 From: AsamK Date: Wed, 9 Sep 2015 16:18:47 +0200 Subject: [PATCH] Hide debug messages from p3historymgr --- libretroshare/src/pqi/p3historymgr.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3historymgr.cc b/libretroshare/src/pqi/p3historymgr.cc index 60f279bd2..c2b173c6a 100644 --- a/libretroshare/src/pqi/p3historymgr.cc +++ b/libretroshare/src/pqi/p3historymgr.cc @@ -34,6 +34,10 @@ #include "rsserver/p3face.h" #include "util/rsstring.h" +/**** + * #define HISTMGR_DEBUG 1 + ***/ + // clean too old messages every 5 minutes // #define MSG_HISTORY_CLEANING_PERIOD 300 @@ -171,7 +175,9 @@ void p3HistoryMgr::cleanOldMessages() { RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/ +#ifdef HISTMGR_DEBUG std::cerr << "****** cleaning old messages." << std::endl; +#endif time_t now = time(NULL) ; bool changed = false ; @@ -185,7 +191,9 @@ void p3HistoryMgr::cleanOldMessages() std::map::iterator lit2 = lit ; ++lit2 ; +#ifdef HISTMGR_DEBUG std::cerr << " removing msg id " << lit->first << ", for peer id " << mit->first << std::endl; +#endif delete lit->second ; mit->second.erase(lit) ; @@ -201,7 +209,9 @@ void p3HistoryMgr::cleanOldMessages() { std::map >::iterator mit2 = mit ; ++mit2 ; - std::cerr << " removing peer id " << mit->first << ", since it has no messages" << std::endl; +#ifdef HISTMGR_DEBUG + std::cerr << " removing peer id " << mit->first << ", since it has no messages" << std::endl; +#endif mMessages.erase(mit) ; mit = mit2 ; @@ -306,7 +316,9 @@ bool p3HistoryMgr::loadList(std::list& load) std::map >::iterator mit = mMessages.find(msgItem->chatPeerId); msgItem->msgId = nextMsgId++; +#ifdef HISTMGR_DEBUG std::cerr << "Loading msg history item: peer id=" << msgItem->chatPeerId << "), msg id =" << msgItem->msgId << std::endl; +#endif if (mit != mMessages.end()) { mit->second.insert(std::make_pair(msgItem->msgId, msgItem)); @@ -344,7 +356,9 @@ bool p3HistoryMgr::loadList(std::list& load) if (sscanf(kit->value.c_str(), "%d", &val) == 1) mMaxStorageDurationSeconds = val ; +#ifdef HISTMGR_DEBUG std::cerr << "Loaded max storage time for history = " << val << " seconds" << std::endl; +#endif continue; } @@ -446,7 +460,9 @@ bool p3HistoryMgr::getMessages(const ChatId &chatId, std::list &msgs if(!chatIdToVirtualPeerId(chatId, chatPeerId)) return false; +#ifdef HISTMGR_DEBUG std::cerr << "Getting history for virtual peer " << chatPeerId << std::endl; +#endif uint32_t foundCount = 0; @@ -467,7 +483,9 @@ bool p3HistoryMgr::getMessages(const ChatId &chatId, std::list &msgs } } } +#ifdef HISTMGR_DEBUG std::cerr << msgs.size() << " messages added." << std::endl; +#endif return true; } @@ -497,7 +515,9 @@ void p3HistoryMgr::clear(const ChatId &chatId) if(!chatIdToVirtualPeerId(chatId, chatPeerId)) return; +#ifdef HISTMGR_DEBUG std::cerr << "********** p3History::clear()called for virtual peer id " << chatPeerId << std::endl; +#endif std::map >::iterator mit = mMessages.find(chatPeerId); if (mit == mMessages.end()) { @@ -523,7 +543,9 @@ void p3HistoryMgr::removeMessages(const std::list &msgIds) std::list removedIds; std::list::iterator iit; +#ifdef HISTMGR_DEBUG std::cerr << "********** p3History::removeMessages called()" << std::endl; +#endif { RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/ @@ -536,7 +558,9 @@ void p3HistoryMgr::removeMessages(const std::list &msgIds) std::map::iterator lit = mit->second.find(*iit); if (lit != mit->second.end()) { +#ifdef HISTMGR_DEBUG std::cerr << "**** Removing " << mit->first << " msg id = " << lit->first << std::endl; +#endif delete(lit->second); mit->second.erase(lit);