ChallyCai/doubango

delay detroy of sip session ,

Closed this issue · 5 comments

What steps will reproduce the problem?
1. i use imsdroid, i see that when the call end ,the tsip_ssession_dtor will 
destroy the session, and then destroy  audio and video session, but it delay 
about ten more seconds to be called, from the debug ,i learn that the stack 
only destroy the session(tsip_ssession_dtor be called ) after some sip timer 
come to end , finaly call tsip_transac_ict_OnTerminated.

2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by openser@yeah.net on 19 Jul 2011 at 7:05

as delay  destroy time of sip session, the onplugindestroy function in java 
will be delay, so if i have another call during this time , the audio and video 
plugin may be destroyed at this time ,from the debug i see the destructor of 
CallSession ,InviteSession, SIpsession ,MediaSessionMgr all be called at onece 
after call end, but it delay to call those ctor in doubango C, so ,may it be 
problem of swig jni mechanism ? 
Any   idear sir ?
thanks .

Original comment by openser@yeah.net on 22 Jul 2011 at 1:19

To be honest I don't understand the problem at all :)
The framework use reference counting mechanism which means that a C/C++ object 
will be destroyed only after the "refcount" value reach zero. 

When you make hangup a call the SIP "BYE" request will create a new client 
transaction which has a reference on the INVITE dialog. And the dialog holds a 
reference on of the SipSession.
This means that the dialog will be destroyed after the transaction object as 
the later has a reference of the former. 
In SIP after a client transaction receive a final response (in this case 2xx 
BYE) you have raise a timer ("K") in order to absorb retransmission or 
out-of-order requests. This means that or transaction object will only be 
destroyed when the timer "K" timeout.

This said, InviteSession, CallSession ... are just C++ wrappers around ANSI-C 
objects. The life-cycle of these object is managed by java garbage collector 
which means that the dtors are only called when you no longer hold any 
reference in our java code. Take care: The garbage collector will not collect 
the objects immediately, it's system dependent.

Original comment by boss...@yahoo.fr on 22 Jul 2011 at 2:04

  • Changed state: Done
the fallow is debug log .
we see mRefCount is 0 in time 10:50, but the destructor is called about 10 
senconds later . so it delay to remove mediaSessionMgr plugins .


D/org.doubango.imsdroid.Screens.ScreenAV( 1178): onStop()
D/org.doubango.imsdroid.Screens.ScreenAV( 1178): onDestroy()
D/org.doubango.imsdroid.Screens.ScreenAV( 1178): release invite session 
I/tinyWRAP( 1178): [Jan  2 03:10:50] DEBUG[1178]: 
../../_common/SipSession.cxx:358 virtual CallSession::~CallSession(): 
I/tinyWRAP( 1178): callsesion
I/tinyWRAP( 1178): [Jan  2 03:10:50] DEBUG[1178]: 
../../_common/SipSession.cxx:206 virtual InviteSession::~InviteSession(): 
I/tinyWRAP( 1178): destroy invite session media mgr
I/tinyWRAP( 1178): [Jan  2 03:10:50] DEBUG[1178]: 
../../_common/MediaSessionMgr.cxx:28 void* __droid_destroy_mgr(void*): 
I/tinyWRAP( 1178): destroy mgr session
I/tinyWRAP( 1178): [Jan  2 03:10:50] DEBUG[1178]: 
../../_common/SipSession.cxx:55 virtual SipSession::~SipSession(): 
I/tinyWRAP( 1178): destroy sipSession
D/org.doubango.ngn.sip.NgnSipSession( 1178): destroy this session
D/org.doubango.ngn.sip.NgnSipSession( 1178): mRefCount=0




I/tinyWRAP( 1178): [Jan  2 03:10:53] DEBUG[1178]: src/tsk_timer.c:312 
__tsk_timer_manager_mainthread: 
I/tinyWRAP( 1178): Timer raise 56
I/tinyWRAP( 1178): [Jan  2 03:10:53] DEBUG[1178]: 
src/transactions/tsip_transac_nict.c:189 tsip_transac_nict_timer_callback: 
I/tinyWRAP( 1178): none invite client transac timer
I/tinyWRAP( 1178): [Jan  2 03:10:53] DEBUG[1178]: src/tsk_fsm.c:158 
tsk_fsm_act: 
I/tinyWRAP( 1178): State machine: 
tsip_transac_nict_Completed_2_Terminated_X_timerK
I/tinyWRAP( 1178): [Jan  2 03:10:53] DEBUG[1178]: src/tsk_fsm.c:188 
tsk_fsm_act: 
I/tinyWRAP( 1178): fsm on terminal state
I/tinyWRAP( 1178): [Jan  2 03:10:53] DEBUG[1178]: 
src/transactions/tsip_transac_nict.c:648 tsip_transac_nict_OnTerminated: 
I/tinyWRAP( 1178): === NICT terminated ===
I/tinyWRAP( 1178): *** NICT destroyed ***




I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tsk_timer.c:312 
__tsk_timer_manager_mainthread: 
I/tinyWRAP( 1178): Timer raise 53
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tsk_fsm.c:158 
tsk_fsm_act: 
I/tinyWRAP( 1178): State machine: tsip_transac_ist_Accepted_2_Terminated_timerL
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tsk_fsm.c:188 
tsk_fsm_act: 
I/tinyWRAP( 1178): fsm on terminal state
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
src/transactions/tsip_transac_ist.c:696 tsip_transac_ist_OnTerminated: 
I/tinyWRAP( 1178): === IST terminated ===
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tsip_ssession.c:582 
tsip_ssession_dtor: 
I/tinyWRAP( 1178): *** SIP Session destroyed ***
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tmedia_session.c:1291 
tmedia_session_mgr_dtor: 
I/tinyWRAP( 1178): dectroy all video audio session
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
src/audio/tdav_session_audio.c:830 tdav_session_audio_dtor: 
I/tinyWRAP( 1178): destroy audio sessions
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
src/audio/tdav_session_audio.c:849 tdav_session_audio_dtor: 
I/tinyWRAP( 1178): destroyed audio producer and consumer
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tmedia_consumer.c:158 
tmedia_consumer_deinit: 
I/tinyWRAP( 1178): deinit
D/org.doubango.ngn.media.NgnProxyPluginMgr( 1178): 
OnPluginDestroyed(21,twrap_proxy_plugin_audio_consumer)
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tmedia_producer.c:175 
tmedia_producer_deinit: 
I/tinyWRAP( 1178): deinit producer
D/org.doubango.ngn.media.NgnProxyPluginMgr( 1178): 
OnPluginDestroyed(22,twrap_proxy_plugin_audio_producer)
E/tinyWRAP( 1178): ***ERROR: function: "tsk_list_lock()" 
E/tinyWRAP( 1178): file: "src/tsk_list.c" 
E/tinyWRAP( 1178): line: "84" 
E/tinyWRAP( 1178): MSG: Invalid parameter
E/tinyWRAP( 1178): ***ERROR: function: "tsk_list_unlock()" 
E/tinyWRAP( 1178): file: "src/tsk_list.c" 
E/tinyWRAP( 1178): line: "101" 
E/tinyWRAP( 1178): MSG: Invalid parameter
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
src/video/tdav_session_video.c:676 tdav_session_video_dtor: 
I/tinyWRAP( 1178): destroy video consumer and producer
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tmedia_consumer.c:158 
tmedia_consumer_deinit: 
I/tinyWRAP( 1178): deinit
D/org.doubango.ngn.media.NgnProxyPluginMgr( 1178): 
OnPluginDestroyed(23,twrap_proxy_plugin_video_consumer)
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
../../_common/ProxyProducer.cxx:374 tsk_object_t* 
twrap_producer_proxy_video_dtor(tsk_obj: 
I/tinyWRAP( 1178): proxy video dtor
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: src/tmedia_producer.c:175 
tmedia_producer_deinit: 
I/tinyWRAP( 1178): deinit producer
D/org.doubango.ngn.media.NgnProxyPluginMgr( 1178): 
OnPluginDestroyed(24,twrap_proxy_plugin_video_producer)
E/tinyWRAP( 1178): ***ERROR: function: "tdav_codec_h264_close()" 
E/tinyWRAP( 1178): file: "src/codecs/h264/tdav_codec_h264.c" 
E/tinyWRAP( 1178): line: "276" 
I/tinyWRAP( 1178): [Jan  2 03:11:13] DEBUG[1178]: 
src/dialogs/tsip_dialog_invite.c:1450 tsip_dialog_invite_dtor: 
I/tinyWRAP( 1178): *** INVITE Dialog destroyed ***
I/tinyWRAP( 1178): *** IST destroyed ***


Original comment by openser@yeah.net on 22 Jul 2011 at 3:39

and the C++ destrouctor :
~CallSession(): 
~InviteSession(): 
:~SipSession(): 
called at  10:50 but the dtor in c is 20s later.

Original comment by openser@yeah.net on 22 Jul 2011 at 3:52

All is working as expected.
SipSession only holds a reference to "tsip_ssession_t". The ANSI-c dtor will be 
called when the "refcount" value reach zero.
What is the problem?

Original comment by boss...@yahoo.fr on 22 Jul 2011 at 1:17