From 88d3811871fb5577d2ce987dcc34587d9e748f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 10 May 2016 14:44:20 +0200 Subject: [PATCH] Fixes memory leak in "Eject from 4 participants conference" tester --- coreapi/conference.cc | 22 +++++++++++--------- coreapi/conference_private.h | 2 +- tester/multi_call_tester.c | 40 +++++++++++++++++++----------------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/coreapi/conference.cc b/coreapi/conference.cc index 48c46fdc5..eb624e516 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -289,7 +289,7 @@ const char *Conference::stateToString(LinphoneConferenceState state) { switch(state) { case LinphoneConferenceStopped: return "Stopped"; case LinphoneConferenceStarting: return "Starting"; - case LinphoneConferenceReady: return "Ready"; + case LinphoneConferenceRunning: return "Ready"; case LinphoneConferenceStartingFailed: return "Startig failed"; default: return "Invalid state"; } @@ -331,7 +331,7 @@ LocalConference::LocalConference(LinphoneCore *core, const Conference::Params *p MSAudioConferenceParams ms_conf_params; ms_conf_params.samplerate = lp_config_get_int(m_core->config, "sound","conference_rate",16000); m_conf=ms_audio_conference_new(&ms_conf_params, core->factory); - m_state=LinphoneConferenceReady; + m_state= LinphoneConferenceRunning; } LocalConference::~LocalConference() { @@ -589,6 +589,7 @@ void LocalConference::onCallStreamStarting(LinphoneCall *call, bool isPausedByRe ms_audio_conference_add_member(m_conf,ep); ms_audio_conference_mute_member(m_conf,ep,isPausedByRemote); call->endpoint=ep; + setState(LinphoneConferenceRunning); } void LocalConference::onCallStreamStopping(LinphoneCall *call) { @@ -610,6 +611,7 @@ void LocalConference::onCallTerminating(LinphoneCall *call) { ms_audio_conference_remove_member(m_conf, m_recordEndpoint); ms_audio_endpoint_destroy(m_recordEndpoint); } + setState(LinphoneConferenceStopped); } } @@ -672,7 +674,7 @@ int RemoteConference::addParticipant(LinphoneCall *call) { } return 0; - case LinphoneConferenceReady: + case LinphoneConferenceRunning: Conference::addParticipant(call); transferToFocus(call); return 0; @@ -689,7 +691,7 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) { int res; switch(m_state) { - case LinphoneConferenceReady: + case LinphoneConferenceRunning: if(findParticipant(uri) == NULL) { char *tmp = linphone_address_as_string(uri); ms_error("Conference: could not remove participant '%s': not in the participants list", tmp); @@ -723,7 +725,7 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) { int RemoteConference::terminate() { m_isTerminating = true; switch(m_state) { - case LinphoneConferenceReady: + case LinphoneConferenceRunning: case LinphoneConferenceStarting: linphone_core_terminate_call(m_core, m_focusCall); reset(); @@ -741,7 +743,7 @@ int RemoteConference::terminate() { } int RemoteConference::enter() { - if(m_state != LinphoneConferenceReady) { + if(m_state != LinphoneConferenceRunning) { ms_error("Could not enter in the conference: bad conference state (%s)", stateToString(m_state)); return -1; } @@ -759,7 +761,7 @@ int RemoteConference::enter() { } int RemoteConference::leave() { - if(m_state != LinphoneConferenceReady) { + if(m_state != LinphoneConferenceRunning) { ms_error("Could not leave the conference: bad conference state (%s)", stateToString(m_state)); return -1; } @@ -777,7 +779,7 @@ int RemoteConference::leave() { } bool RemoteConference::isIn() const { - if(m_state != LinphoneConferenceReady) return false; + if(m_state != LinphoneConferenceRunning) return false; LinphoneCallState callState = linphone_call_get_state(m_focusCall); return callState == LinphoneCallStreamsRunning; } @@ -830,7 +832,7 @@ void RemoteConference::onFocusCallSateChanged(LinphoneCallState state) { it = it->next; } } - setState(LinphoneConferenceReady); + setState(LinphoneConferenceRunning); break; case LinphoneCallError: @@ -850,7 +852,7 @@ void RemoteConference::onPendingCallStateChanged(LinphoneCall *call, LinphoneCal switch(state) { case LinphoneCallStreamsRunning: case LinphoneCallPaused: - if(m_state == LinphoneConferenceReady) { + if(m_state == LinphoneConferenceRunning) { m_pendingCalls = ms_list_remove(m_pendingCalls, call); m_transferingCalls = ms_list_append(m_transferingCalls, call); linphone_core_transfer_call(m_core, call, m_focusContact); diff --git a/coreapi/conference_private.h b/coreapi/conference_private.h index bc203f794..eaa649cd1 100644 --- a/coreapi/conference_private.h +++ b/coreapi/conference_private.h @@ -43,7 +43,7 @@ typedef enum { typedef enum { LinphoneConferenceStopped, /*< Initial state */ LinphoneConferenceStarting, /*< A participant has been added but the conference is not running yet */ - LinphoneConferenceReady, /*< The conference is running */ + LinphoneConferenceRunning, /*< The conference is running */ LinphoneConferenceStartingFailed /*< A participant has been added but the initialization of the conference has failed */ } LinphoneConferenceState; /** diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index bd9e6d624..d415e0485 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -805,27 +805,29 @@ static void eject_from_4_participants_conference(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(michelle->lc)); - end_call(laure, marie); - end_call(pauline, marie); - end_call(michelle, marie); - - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallEnd,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&michelle->stat.number_of_LinphoneCallEnd,1,10000)); - - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallReleased,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallReleased,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallReleased,1,10000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&michelle->stat.number_of_LinphoneCallReleased,1,10000)); - - ms_list_free(lcs); - + + linphone_core_terminate_all_calls(laure->lc); + linphone_core_terminate_all_calls(pauline->lc); + linphone_core_terminate_all_calls(michelle->lc); + + BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallEnd, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEnd, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &michelle->stat.number_of_LinphoneCallEnd, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallEnd, 3, 10000)); + + BC_ASSERT_PTR_NULL(linphone_core_get_conference(marie->lc)); + + BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallReleased, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallReleased, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &michelle->stat.number_of_LinphoneCallReleased, 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallEnd, 3, 10000)); + end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(michelle); + ms_list_free(lcs); } @@ -931,10 +933,10 @@ test_t multi_call_tests[] = { TEST_NO_TAG("Incoming call accepted when outgoing call in outgoing ringing", incoming_call_accepted_when_outgoing_call_in_outgoing_ringing), TEST_NO_TAG("Incoming call accepted when outgoing call in outgoing ringing early media", incoming_call_accepted_when_outgoing_call_in_outgoing_ringing_early_media), TEST_NO_TAG("Simple conference", simple_conference), - TEST_TWO_TAGS("Simple conference with ICE", simple_conference_with_ice, "ICE",), - TEST_TWO_TAGS("Simple ZRTP conference with ICE", simple_zrtp_conference_with_ice, "ICE",), + TEST_ONE_TAG("Simple conference with ICE", simple_conference_with_ice, "ICE"), + TEST_ONE_TAG("Simple ZRTP conference with ICE", simple_zrtp_conference_with_ice, "ICE"), TEST_NO_TAG("Eject from 3 participants conference", eject_from_3_participants_local_conference), - TEST_ONE_TAG("Eject from 4 participants conference", eject_from_4_participants_conference, "LeaksMemory"), + TEST_NO_TAG("Eject from 4 participants conference", eject_from_4_participants_conference), TEST_NO_TAG("Simple call transfer", simple_call_transfer), TEST_NO_TAG("Unattended call transfer", unattended_call_transfer), TEST_NO_TAG("Unattended call transfer with error", unattended_call_transfer_with_error),