From 72c9fba6d2951c47106bf61a2a46004f1fb3d245 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 1 Nov 2023 21:44:29 +0200 Subject: [PATCH] module-protocol-native: emit error on bad concurrency Emit error if message construction is not holding appropriate locks or runs from wrong thread, so that the flush may be running concurrently. This generally causes corrputed messages to be sent silently, and can be fairly hard to debug otherwise in client applications. --- src/modules/module-protocol-native.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 486eb5561..62b0274a4 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -1489,6 +1489,7 @@ static int impl_ext_end_proxy(struct pw_proxy *proxy, { struct pw_core *core = proxy->core; struct client *impl = SPA_CONTAINER_OF(core->conn, struct client, this); + ensure_loop(impl->context->main_loop); assert_single_pod(builder); marshal_core_footers(&impl->footer_state, core, builder); return core->send_seq = pw_protocol_native_connection_end(impl->connection, builder); @@ -1518,6 +1519,7 @@ static int impl_ext_end_resource(struct pw_resource *resource, { struct client_data *data = resource->client->user_data; struct pw_impl_client *client = resource->client; + ensure_loop(client->context->main_loop); assert_single_pod(builder); marshal_client_footers(&data->footer_state, client, builder); return client->send_seq = pw_protocol_native_connection_end(data->connection, builder);