r3237 - in trunk/libmsip: include/libmsip source

erik at minisip.org erik at minisip.org
Thu Mar 8 05:27:02 CET 2007


Author: erik
Date: 2007-03-08 05:27:01 +0100 (Thu, 08 Mar 2007)
New Revision: 3237

Modified:
   trunk/libmsip/include/libmsip/SipLayerDialog.h
   trunk/libmsip/include/libmsip/SipLayerTransaction.h
   trunk/libmsip/include/libmsip/SipStack.h
   trunk/libmsip/source/SipCommandDispatcher.cxx
   trunk/libmsip/source/SipLayerDialog.cxx
   trunk/libmsip/source/SipLayerTransaction.cxx
   trunk/libmsip/source/SipLayerTransport.cxx
   trunk/libmsip/source/SipStack.cxx
   trunk/libmsip/source/SipStackInternal.cxx
Log:

 * libmsip: Memory leak fixing (break reference loops)



Modified: trunk/libmsip/include/libmsip/SipLayerDialog.h
===================================================================
--- trunk/libmsip/include/libmsip/SipLayerDialog.h	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/include/libmsip/SipLayerDialog.h	2007-03-08 04:27:01 UTC (rev 3237)
@@ -42,6 +42,8 @@
 	public:
 
 		SipLayerDialog(MRef<SipCommandDispatcher*> dispatcher);
+
+		~SipLayerDialog();
 		
 		void setDefaultDialogCommandHandler(MRef<SipDefaultHandler*> cb);
 		MRef<SipDefaultHandler*> getDefaultDialogCommandHandler();

Modified: trunk/libmsip/include/libmsip/SipLayerTransaction.h
===================================================================
--- trunk/libmsip/include/libmsip/SipLayerTransaction.h	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/include/libmsip/SipLayerTransaction.h	2007-03-08 04:27:01 UTC (rev 3237)
@@ -42,6 +42,8 @@
 		SipLayerTransaction(MRef<SipCommandDispatcher*> dispatcher, 
 				MRef<SipLayerTransport*> transp);
 
+		~SipLayerTransaction();
+
 		void doHandleAck(bool b);
 		
 		void removeTransaction(MRef<SipTransaction*> t);

Modified: trunk/libmsip/include/libmsip/SipStack.h
===================================================================
--- trunk/libmsip/include/libmsip/SipStack.h	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/include/libmsip/SipStack.h	2007-03-08 04:27:01 UTC (rev 3237)
@@ -240,6 +240,8 @@
 		SipStack( MRef<SipStackConfig*> stackConfig );
 
 		~SipStack();
+
+		void free();
 		
 		void setTransactionHandlesAck(bool transHandleAck);
 		void setDefaultDialogCommandHandler(MRef<SipDefaultHandler*> cb);

Modified: trunk/libmsip/source/SipCommandDispatcher.cxx
===================================================================
--- trunk/libmsip/source/SipCommandDispatcher.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipCommandDispatcher.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -50,8 +50,10 @@
 }
 
 void SipCommandDispatcher::free(){
+	cerr << "EEEE: Running SipCommandDispatcher::free"<<endl;
 	sipStackInternal=NULL;
 	callback=NULL;
+	managementHandler->freeStateMachine();
 	managementHandler=NULL;
 	transportLayer->setDispatcher(NULL);
 	transportLayer=NULL;
@@ -155,6 +157,7 @@
                 item.transaction_receiver=NULL;
                 item.call_receiver=NULL;
 	}
+	cerr << "EEEE: SipCommandDispatcher::run done - EXITING"<<endl;
 }
 
 void SipCommandDispatcher::setCallback(MRef<CommandReceiver*> callback){

Modified: trunk/libmsip/source/SipLayerDialog.cxx
===================================================================
--- trunk/libmsip/source/SipLayerDialog.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipLayerDialog.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -38,6 +38,15 @@
 	
 }
 
+SipLayerDialog::~SipLayerDialog(){
+	list<MRef<SipDialog*> > l;
+	dialogListLock.lock();
+	for (int i=0; i< dialogs.size(); i++)
+		dialogs[i]->freeStateMachine();;
+	dialogListLock.unlock();
+
+}
+
 list<MRef<SipDialog*> > SipLayerDialog::getDialogs() {
 	list<MRef<SipDialog*> > l;
 	dialogListLock.lock();

Modified: trunk/libmsip/source/SipLayerTransaction.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransaction.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipLayerTransaction.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -45,6 +45,13 @@
 	
 }
 
+SipLayerTransaction::~SipLayerTransaction(){
+	MRef<SipTransaction*> trans;
+	for (int i=0; i<transactions.size(); i++){
+		transactions[i]->freeStateMachine();
+	}
+}
+
 bool SipLayerTransaction::defaultCommandHandler(const SipSMCommand &cmd){
 	
 	MRef<SipTransaction*> newTransaction;

Modified: trunk/libmsip/source/SipLayerTransport.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransport.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipLayerTransport.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -379,6 +379,7 @@
 	}
 
 	manager->join();
+	manager->closeSockets();
 	manager = NULL;
 
 		//wait for the threads in the servers.

Modified: trunk/libmsip/source/SipStack.cxx
===================================================================
--- trunk/libmsip/source/SipStack.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipStack.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -78,11 +78,16 @@
 }
 
 SipStack::~SipStack(){
-	MRef<SipStackInternal*> * mrefPtr = (MRef<SipStackInternal*> *) sipStackInternal;
-	
-	(*mrefPtr)->free();
+	free();
+}
 
-	delete mrefPtr;
+void SipStack::free(){
+	if (sipStackInternal){
+		MRef<SipStackInternal*> * mrefPtr = (MRef<SipStackInternal*> *) sipStackInternal;
+		(*mrefPtr)->free();
+		delete mrefPtr;
+		sipStackInternal=NULL;
+	}
 }
 
 void SipStack::setTransactionHandlesAck(bool transHandlesAck){

Modified: trunk/libmsip/source/SipStackInternal.cxx
===================================================================
--- trunk/libmsip/source/SipStackInternal.cxx	2007-03-08 01:55:27 UTC (rev 3236)
+++ trunk/libmsip/source/SipStackInternal.cxx	2007-03-08 04:27:01 UTC (rev 3237)
@@ -151,12 +151,13 @@
 }
 
 void SipStackInternal::free(){
+	cerr << "EEEE: running SipStackInternal::free"<<endl;
+	timeoutProvider->stopThread();
+	timeoutProvider=NULL;
 	setCallback(NULL);
 	setConfCallback(NULL);
 	dispatcher->free();
 	dispatcher=NULL;
-	timeoutProvider->stopThread();
-	timeoutProvider=NULL;
 }
 
 MRef<SipStackConfig*> SipStackInternal::getStackConfig(){



More information about the Minisip-devel mailing list