74 lines
1.8 KiB
Diff
74 lines
1.8 KiB
Diff
From c9f2b4222cf51a259b77ed4e83c45f6a08884cb8 Mon Sep 17 00:00:00 2001
|
|
From: Ondrej Holy <oholy@redhat.com>
|
|
Date: Fri, 13 Mar 2026 15:46:17 +0100
|
|
Subject: [PATCH] [channels,rdpsnd] terminate thread before free
|
|
|
|
Backport of commit 622bb7b4402491ca003f47472d0e478132673696.
|
|
|
|
Made-with: Cursor
|
|
---
|
|
channels/rdpsnd/client/rdpsnd_main.c | 28 ++++++++++++++++++++--------
|
|
1 file changed, 20 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c
|
|
index 3de4cbc66..c7660a857 100644
|
|
--- a/channels/rdpsnd/client/rdpsnd_main.c
|
|
+++ b/channels/rdpsnd/client/rdpsnd_main.c
|
|
@@ -36,6 +36,7 @@
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
+#include <winpr/assert.h>
|
|
#include <winpr/crt.h>
|
|
#include <winpr/wlog.h>
|
|
#include <winpr/stream.h>
|
|
@@ -1244,11 +1245,29 @@ fail:
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
}
|
|
|
|
+static void rdpsnd_terminate_thread(rdpsndPlugin* rdpsnd)
|
|
+{
|
|
+ WINPR_ASSERT(rdpsnd);
|
|
+ if (rdpsnd->queue)
|
|
+ MessageQueue_PostQuit(rdpsnd->queue, 0);
|
|
+
|
|
+ if (rdpsnd->thread)
|
|
+ {
|
|
+ (void)WaitForSingleObject(rdpsnd->thread, INFINITE);
|
|
+ (void)CloseHandle(rdpsnd->thread);
|
|
+ }
|
|
+
|
|
+ MessageQueue_Free(rdpsnd->queue);
|
|
+ rdpsnd->thread = NULL;
|
|
+ rdpsnd->queue = NULL;
|
|
+}
|
|
+
|
|
static void cleanup_internals(rdpsndPlugin* rdpsnd)
|
|
{
|
|
if (!rdpsnd)
|
|
return;
|
|
|
|
+ rdpsnd_terminate_thread(rdpsnd);
|
|
if (rdpsnd->pool)
|
|
StreamPool_Return(rdpsnd->pool, rdpsnd->data_in);
|
|
|
|
@@ -1396,14 +1415,7 @@ void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
|
{
|
|
if (rdpsnd)
|
|
{
|
|
- if (rdpsnd->queue)
|
|
- MessageQueue_PostQuit(rdpsnd->queue, 0);
|
|
- if (rdpsnd->thread)
|
|
- {
|
|
- WaitForSingleObject(rdpsnd->thread, INFINITE);
|
|
- CloseHandle(rdpsnd->thread);
|
|
- }
|
|
- MessageQueue_Free(rdpsnd->queue);
|
|
+ rdpsnd_terminate_thread(rdpsnd);
|
|
|
|
free_internals(rdpsnd);
|
|
audio_formats_free(rdpsnd->fixed_format, 1);
|
|
--
|
|
2.53.0
|
|
|