mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-06 22:53:02 +00:00
add more code to free rtp ports
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6913 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
69b726ec1b
commit
36d84006eb
@ -75,7 +75,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port);
|
|||||||
\return the new port to use
|
\return the new port to use
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip);
|
SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip);
|
||||||
|
SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port);
|
||||||
/*!
|
/*!
|
||||||
\brief create a new RTP session handle
|
\brief create a new RTP session handle
|
||||||
\param new_rtp_session a poiter to aim at the new session
|
\param new_rtp_session a poiter to aim at the new session
|
||||||
|
@ -687,6 +687,11 @@ static void terminate_session(switch_core_session_t **session, int line, switch_
|
|||||||
|
|
||||||
tech_pvt = switch_core_session_get_private(*session);
|
tech_pvt = switch_core_session_get_private(*session);
|
||||||
|
|
||||||
|
|
||||||
|
if (tech_pvt->profile->ip && tech_pvt->local_port) {
|
||||||
|
switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port);
|
||||||
|
}
|
||||||
|
|
||||||
if (!switch_core_session_running(*session) && (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY))) {
|
if (!switch_core_session_running(*session) && (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY))) {
|
||||||
switch_core_session_destroy(session);
|
switch_core_session_destroy(session);
|
||||||
return;
|
return;
|
||||||
@ -1209,6 +1214,10 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
switch_assert(tech_pvt != NULL);
|
switch_assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
if (tech_pvt->profile->ip && tech_pvt->local_port) {
|
||||||
|
switch_rtp_release_port(tech_pvt->profile->ip, tech_pvt->local_port);
|
||||||
|
}
|
||||||
|
|
||||||
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
|
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
|
||||||
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
|
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
|
||||||
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
|
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
|
||||||
|
@ -201,7 +201,10 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||||||
|
|
||||||
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||||
switch_assert(tech_pvt != NULL);
|
switch_assert(tech_pvt != NULL);
|
||||||
|
|
||||||
|
if (tech_pvt->profile->rtpip && tech_pvt->local_sdp_audio_port) {
|
||||||
|
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
||||||
const char *buuid;
|
const char *buuid;
|
||||||
|
@ -316,16 +316,16 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port)
|
|||||||
return END_PORT;
|
return END_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void release_port(const char *host, switch_port_t port)
|
SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port)
|
||||||
{
|
{
|
||||||
switch_core_port_allocator_t *alloc = NULL;
|
switch_core_port_allocator_t *alloc = NULL;
|
||||||
|
|
||||||
if (!host) {
|
if (!ip) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_lock(port_lock);
|
switch_mutex_lock(port_lock);
|
||||||
if ((alloc = switch_core_hash_find(alloc_hash, host))) {
|
if ((alloc = switch_core_hash_find(alloc_hash, ip))) {
|
||||||
switch_core_port_allocator_free_port(alloc, port);
|
switch_core_port_allocator_free_port(alloc, port);
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(port_lock);
|
switch_mutex_unlock(port_lock);
|
||||||
@ -634,7 +634,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
|
|||||||
rtp_session->rx_host = switch_core_strdup(rtp_session->pool, rx_host);
|
rtp_session->rx_host = switch_core_strdup(rtp_session->pool, rx_host);
|
||||||
rtp_session->rx_port = rx_port;
|
rtp_session->rx_port = rx_port;
|
||||||
} else {
|
} else {
|
||||||
release_port(rx_host, rx_port);
|
switch_rtp_release_port(rx_host, rx_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtp_session;
|
return rtp_session;
|
||||||
@ -731,7 +731,7 @@ SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session)
|
|||||||
switch_core_timer_destroy(&(*rtp_session)->timer);
|
switch_core_timer_destroy(&(*rtp_session)->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
release_port((*rtp_session)->rx_host, (*rtp_session)->rx_port);
|
switch_rtp_release_port((*rtp_session)->rx_host, (*rtp_session)->rx_port);
|
||||||
|
|
||||||
switch_mutex_unlock((*rtp_session)->flag_mutex);
|
switch_mutex_unlock((*rtp_session)->flag_mutex);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user