From: Jack Lau <jacklau1222gm@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Jack Lau <jacklau1222@qq.com> Subject: [FFmpeg-devel] [PATCH v3 4/9] avformat/tls_openssl: make tls and dtls use one close function Date: Sun, 13 Jul 2025 15:09:45 +0800 Message-ID: <20250713070950.10626-5-jacklau1222@qq.com> (raw) In-Reply-To: <20250713070950.10626-1-jacklau1222@qq.com> Signed-off-by: Jack Lau <jacklau1222@qq.com> --- libavformat/tls_openssl.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index c824c5452b..3ed4585ecf 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -553,9 +553,16 @@ static int tls_close(URLContext *h) } if (c->ctx) SSL_CTX_free(c->ctx); - ffurl_closep(&c->tls_shared.tcp); + if (c->tls_shared.external_sock != 1) + ffurl_closep(c->tls_shared.is_dtls ? &c->tls_shared.udp : &c->tls_shared.tcp); + if (c->tls_shared.cert_buf) + av_freep(&c->tls_shared.cert_buf); + if (c->tls_shared.key_buf) + av_freep(&c->tls_shared.key_buf); if (c->url_bio_method) BIO_meth_free(c->url_bio_method); + if (c->pkey) + EVP_PKEY_free(c->pkey); return 0; } @@ -875,20 +882,6 @@ fail: return ret; } -/** - * Cleanup the DTLS context. - */ -static av_cold int dtls_close(URLContext *h) -{ - TLSContext *ctx = h->priv_data; - SSL_free(ctx->ssl); - SSL_CTX_free(ctx->ctx); - av_freep(&ctx->tls_shared.cert_buf); - av_freep(&ctx->tls_shared.key_buf); - EVP_PKEY_free(ctx->pkey); - return 0; -} - static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) { TLSContext *p = h->priv_data; @@ -1032,7 +1025,7 @@ const URLProtocol ff_dtls_protocol = { .name = "dtls", .url_open2 = dtls_start, .url_handshake = dtls_handshake, - .url_close = dtls_close, + .url_close = tls_close, .url_read = tls_read, .url_write = tls_write, .url_get_file_handle = tls_get_file_handle, -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-07-13 7:10 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-07-13 7:09 [FFmpeg-devel] [PATCH v3 0/9] Fix some issues in tls_openssl Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 1/9] avformat/tls: add trace function for log TLS/DTLS record Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 2/9] avformat/tls_openssl: fix dtls_handshake return code Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 3/9] avformat/tls_openssl: remove all redundant "TLS: " in log with AVClass Jack Lau 2025-07-13 7:09 ` Jack Lau [this message] 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 5/9] avformat/whip: free udp socket after dtls free Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 6/9] avformat/tls_openssl: replace 1 to TLS_ST_OK to be more clear Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 7/9] avformat/tls_openssl: remove requirement for dtls must init cert and key Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 8/9] avformat/tls_openssl: auto set the dest addr when dtls in listen mode Jack Lau 2025-07-13 7:09 ` [FFmpeg-devel] [PATCH v3 9/9] avformat/tls_openssl: init DTLS context with explicit method Jack Lau
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250713070950.10626-5-jacklau1222@qq.com \ --to=jacklau1222gm@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=jacklau1222@qq.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git