diff --git a/pjlib/src/pj/ssl_sock_imp_common.h b/pjlib/src/pj/ssl_sock_imp_common.h index af7c0ea694..14ee122da8 100644 --- a/pjlib/src/pj/ssl_sock_imp_common.h +++ b/pjlib/src/pj/ssl_sock_imp_common.h @@ -230,7 +230,7 @@ inline static void io_read(pj_ssl_sock_t *ssock, circ_buf_t *cb, pj_uint8_t *dst, pj_size_t len) { PJ_UNUSED_ARG(ssock); - return circ_read(cb, dst, len); + circ_read(cb, dst, len); } inline static pj_status_t io_write(pj_ssl_sock_t *ssock, circ_buf_t *cb, const pj_uint8_t *src, pj_size_t len) diff --git a/pjmedia/src/pjmedia/event.c b/pjmedia/src/pjmedia/event.c index b8565dba69..30ae9ce311 100644 --- a/pjmedia/src/pjmedia/event.c +++ b/pjmedia/src/pjmedia/event.c @@ -243,6 +243,8 @@ PJ_DEF(void) pjmedia_event_mgr_destroy(pjmedia_event_mgr *mgr) mgr->is_quitting = PJ_TRUE; pj_sem_post(mgr->sem); pj_thread_join(mgr->thread); + pj_thread_destroy(mgr->thread); + mgr->thread = NULL; } if (mgr->sem) { diff --git a/pjmedia/src/pjmedia/transport_srtp_dtls.c b/pjmedia/src/pjmedia/transport_srtp_dtls.c index 3a3981981e..97c2f3ec01 100644 --- a/pjmedia/src/pjmedia/transport_srtp_dtls.c +++ b/pjmedia/src/pjmedia/transport_srtp_dtls.c @@ -293,7 +293,7 @@ static pj_status_t dtls_create(transport_srtp *srtp, pj_grp_lock_add_ref(grp_lock); pj_grp_lock_add_handler(grp_lock, pool, ds, &dtls_on_destroy); } else { - status = pj_lock_create_simple_mutex(ds->pool, "dtls_ssl_lock%p", + status = pj_lock_create_recursive_mutex(ds->pool, "dtls_ssl_lock%p", &ds->ossl_lock); if (status != PJ_SUCCESS) return status; diff --git a/pjnath/src/pjnath/turn_sock.c b/pjnath/src/pjnath/turn_sock.c index 36ddaff700..e5b73d4299 100644 --- a/pjnath/src/pjnath/turn_sock.c +++ b/pjnath/src/pjnath/turn_sock.c @@ -1183,6 +1183,8 @@ static void turn_on_state(pj_turn_session *sess, (*turn_sock->cb.on_state)(turn_sock, old_state, new_state); } + pj_grp_lock_acquire(turn_sock->grp_lock); + /* Make sure user hasn't destroyed us in the callback */ if (turn_sock->sess && new_state == PJ_TURN_STATE_RESOLVED) { pj_turn_session_info info; @@ -1250,6 +1252,7 @@ static void turn_on_state(pj_turn_session *sess, status = pj_sock_socket(turn_sock->af, sock_type, 0, &sock); if (status != PJ_SUCCESS) { turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } @@ -1260,6 +1263,7 @@ static void turn_on_state(pj_turn_session *sess, if (status != PJ_SUCCESS) { pj_sock_close(sock); turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } /* Apply QoS, if specified */ @@ -1271,6 +1275,7 @@ static void turn_on_state(pj_turn_session *sess, { pj_sock_close(sock); turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } @@ -1387,6 +1392,7 @@ static void turn_on_state(pj_turn_session *sess, } if (status != PJ_SUCCESS) { turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } if (turn_sock->cert) { @@ -1398,6 +1404,7 @@ static void turn_on_state(pj_turn_session *sess, if (status != PJ_SUCCESS) { turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } @@ -1415,6 +1422,7 @@ static void turn_on_state(pj_turn_session *sess, if (status != PJ_SUCCESS) { turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } @@ -1457,6 +1465,7 @@ static void turn_on_state(pj_turn_session *sess, pj_sockaddr_print(&info.server, addrtxt, sizeof(addrtxt), 3))); turn_sock_destroy(turn_sock, status); + pj_grp_lock_release(turn_sock->grp_lock); return; } @@ -1478,6 +1487,8 @@ static void turn_on_state(pj_turn_session *sess, &delay, TIMER_DESTROY, turn_sock->grp_lock); } + + pj_grp_lock_release(turn_sock->grp_lock); } diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 2fe61b5ad1..b7dde8bdd3 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -3400,8 +3400,8 @@ static pj_bool_t is_ice_running(pjmedia_transport *tp) static void check_srtp_roc(pjsua_call *call, unsigned med_idx, const pjsua_stream_info *new_si_, - const pjmedia_sdp_media *local_sdp, - const pjmedia_sdp_media *remote_sdp) + const pjmedia_sdp_session *local_sdp, + const pjmedia_sdp_session *rem_sdp) { pjsua_call_media *call_med = &call->media[med_idx]; pjmedia_transport_info tpinfo; @@ -3528,11 +3528,19 @@ static void check_srtp_roc(pjsua_call *call, pjmedia_sdp_attr *attr; if (local_change) { - attr = pjmedia_sdp_attr_find(local_sdp->attr_count, - local_sdp->attr, &STR_ICE_UFRAG, + pjmedia_sdp_media *local_m = local_sdp->media[med_idx]; + + attr = pjmedia_sdp_attr_find(local_m->attr_count, + local_m->attr, &STR_ICE_UFRAG, NULL); - if (!pj_strcmp(&call_med->prev_ice_info.loc_ufrag, - &attr->value)) + if (attr == NULL) { + /* Find ice-ufrag attribute in session level */ + attr = pjmedia_sdp_attr_find(local_sdp->attr_count, + local_sdp->attr, &STR_ICE_UFRAG, + NULL); + } + if (attr && !pj_strcmp(&call_med->prev_ice_info.loc_ufrag, + &attr->value)) { PJ_LOG(4, (THIS_FILE, "ICE unchanged, SRTP TX ROC " "maintained")); @@ -3541,11 +3549,19 @@ static void check_srtp_roc(pjsua_call *call, } if (rem_change) { - attr = pjmedia_sdp_attr_find(remote_sdp->attr_count, - remote_sdp->attr, &STR_ICE_UFRAG, + pjmedia_sdp_media *rem_m = rem_sdp->media[med_idx]; + + attr = pjmedia_sdp_attr_find(rem_m->attr_count, + rem_m->attr, &STR_ICE_UFRAG, NULL); - if (!pj_strcmp(&call_med->prev_ice_info.rem_ufrag, - &attr->value)) + if (attr == NULL) { + /* Find ice-ufrag attribute in session level */ + attr = pjmedia_sdp_attr_find(rem_sdp->attr_count, + rem_sdp->attr, &STR_ICE_UFRAG, + NULL); + } + if (attr && !pj_strcmp(&call_med->prev_ice_info.rem_ufrag, + &attr->value)) { PJ_LOG(4, (THIS_FILE, "ICE unchanged, SRTP RX ROC " "maintained")); @@ -4003,8 +4019,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, #if PJSUA_MEDIA_HAS_PJMEDIA || PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) /* Check if we need to reset or maintain SRTP ROC */ - check_srtp_roc(call, mi, &stream_info, - local_sdp->media[mi], remote_sdp->media[mi]); + check_srtp_roc(call, mi, &stream_info, local_sdp, remote_sdp); #endif #endif @@ -4260,8 +4275,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, #if PJSUA_MEDIA_HAS_PJMEDIA || PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) /* Check if we need to reset or maintain SRTP ROC */ - check_srtp_roc(call, mi, &stream_info, - local_sdp->media[mi], remote_sdp->media[mi]); + check_srtp_roc(call, mi, &stream_info, local_sdp, remote_sdp); #endif #endif