void janus_dtls_srtp_destroy(janus_dtls_srtp *dtls) { if(dtls == NULL) return; #ifdef HAVE_SCTP /* Destroy the SCTP association if this is a DataChannel */ if(dtls->sctp != NULL) { janus_sctp_association_destroy(dtls->sctp); dtls->sctp = NULL; } #endif /* Destroy DTLS stack and free resources */ dtls->component = NULL; if(dtls->ssl != NULL) { SSL_free(dtls->ssl); dtls->ssl = NULL; } /* BIOs are destroyed by SSL_free */ dtls->read_bio = NULL; dtls->write_bio = NULL; dtls->filter_bio = NULL; if(dtls->srtp_valid) { if(dtls->srtp_in) { srtp_dealloc(dtls->srtp_in); dtls->srtp_in = NULL; } if(dtls->srtp_out) { srtp_dealloc(dtls->srtp_out); dtls->srtp_out = NULL; } /* FIXME What about dtls->remote_policy and dtls->local_policy? */ } g_free(dtls); dtls = NULL; }
void janus_dtls_srtp_destroy(janus_dtls_srtp *dtls) { if(!dtls || !g_atomic_int_compare_and_exchange(&dtls->destroyed, 0, 1)) return; dtls->ready = 0; dtls->retransmissions = 0; #ifdef HAVE_SCTP /* Destroy the SCTP association if this is a DataChannel */ if(dtls->sctp != NULL) { janus_sctp_association_destroy(dtls->sctp); janus_refcount_decrease(&dtls->sctp->ref); dtls->sctp = NULL; } #endif janus_refcount_decrease(&dtls->ref); }