diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 6ae324e0ca..a91f937708 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -553,8 +553,11 @@ SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session) { assert(rtp_session != NULL); switch_mutex_lock(rtp_session->flag_mutex); - apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE); - switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO); + if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) { + assert(rtp_session->sock != NULL); + apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE); + switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO); + } switch_mutex_unlock(rtp_session->flag_mutex); }