Commit 1e3e78b9 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

in debug mode, track msg allocations so that when flexisip exits, it dumps that list.

parent 48b11e03
......@@ -59,7 +59,7 @@ MsgSip::~MsgSip() {
SipEvent::SipEvent(const shared_ptr<IncomingAgent> &inAgent, const shared_ptr<MsgSip> & msgSip) :
mCurrModule(NULL), mMsgSip(msgSip), mState(STARTED) {
LOGD("New SipEvent %p", this);
LOGD("New SipEvent %p - msg %p", this, msgSip->getMsg());
mIncomingAgent = inAgent;
mAgent=inAgent->getAgent();
shared_ptr<IncomingTransaction> it=dynamic_pointer_cast<IncomingTransaction>(inAgent);
......@@ -72,7 +72,7 @@ SipEvent::SipEvent(const shared_ptr<IncomingAgent> &inAgent, const shared_ptr<Ms
SipEvent::SipEvent(const shared_ptr<OutgoingAgent> &outAgent, const shared_ptr<MsgSip> & msgSip) :
mCurrModule(NULL), mMsgSip(msgSip), mState(STARTED) {
LOGD("New SipEvent %p", this);
LOGD("New SipEvent %p - %p", this, msgSip->getMsg());
mOutgoingAgent = outAgent;
mAgent=outAgent->getAgent();
shared_ptr<OutgoingTransaction> ot=dynamic_pointer_cast<OutgoingTransaction>(outAgent);
......
......@@ -48,6 +48,7 @@
#include "configdumper.hh"
#include <sofia-sip/su_log.h>
#include <sofia-sip/msg.h>
#ifdef ENABLE_SNMP
#include "snmp-agent.h"
#endif
......@@ -109,6 +110,29 @@ static void timerfunc(su_root_magic_t *magic, su_timer_t *t, Agent *a) {
a->idle();
}
static std::map<msg_t*, string> msg_map;
static void flexisip_msg_create(msg_t* msg){
msg_map[msg] = "";
LOGE("New <-> msg %p", msg);
}
static void flexisip_msg_destroy(msg_t* msg){
auto it = msg_map.find(msg);
if( it != msg_map.end()){
msg_map.erase(it);
}
}
static void dump_remaining_msgs(){
LOGE("Remaining messages: %lu", msg_map.size());
size_t size;
for( auto it = msg_map.begin(); it != msg_map.end(); ++it){
size = SIZE_MAX;
LOGE("\t- %p\n%s", it->first, msg_as_string(msg_home(it->first), it->first, NULL, 0, &size));
}
}
static int getSystemFdLimit() {
static int max_sys_fd = -1;
......@@ -677,6 +701,8 @@ int main(int argc, char *argv[]) {
presenceServer.start();
#endif //ENABLE_PRESENCE
if( debug )
msg_set_callbacks(flexisip_msg_create, flexisip_msg_destroy);
su_timer_t *timer = su_timer_create(su_root_task(root), 5000);
su_timer_set_for_ever(timer, (su_timer_f)timerfunc, a.get());
......@@ -689,6 +715,7 @@ int main(int argc, char *argv[]) {
}
su_root_destroy(root);
LOGN("Flexisip exiting normally.");
dump_remaining_msgs();
GenericManager::get()->sendTrap("Flexisip exiting normally");
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment