From 95d45e4206144a0b72bad99b03d784f2cad64219 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 23 Mar 2018 13:29:46 +0100 Subject: [PATCH] proxy: reuse id when server removed it reset number of fds before we begin reading. When we destroy the proxy, just clear the id. We then remove the id completely when the server sends a remove_id request. This avoid reusing the proxy id before the server has finished with it. Add some debug --- src/modules/module-protocol-native/connection.c | 1 + src/pipewire/proxy.c | 2 +- src/pipewire/remote.c | 1 + src/pipewire/stream.c | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/module-protocol-native/connection.c b/src/modules/module-protocol-native/connection.c index 881669735..817e5b56a 100644 --- a/src/modules/module-protocol-native/connection.c +++ b/src/modules/module-protocol-native/connection.c @@ -158,6 +158,7 @@ static bool refill_buffer(struct pw_protocol_native_connection *conn, struct buf buf->buffer_size += len; /* handle control messages */ + buf->n_fds = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) continue; diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index d7c91e2b9..4a87b07be 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -121,7 +121,7 @@ void pw_proxy_destroy(struct pw_proxy *proxy) pw_log_debug("proxy %p: destroy %u", proxy, proxy->id); spa_hook_list_call(&proxy->listener_list, struct pw_proxy_events, destroy); - pw_map_remove(&proxy->remote->objects, proxy->id); + pw_map_insert_at(&proxy->remote->objects, proxy->id, NULL); spa_list_remove(&proxy->link); free(impl); diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 8f46bc692..7d65ce514 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -189,6 +189,7 @@ static void core_event_remove_id(void *data, uint32_t id) pw_log_debug("remote %p: object remove %u", this, id); pw_proxy_destroy(proxy); } + pw_map_remove(&this->objects, id); } static void diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index c63d213fd..da95dad2a 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -642,6 +642,8 @@ static int handle_connect(struct pw_stream *stream) { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); + pw_log_debug("stream %p: creating proxy", stream); + impl->node = pw_node_new(impl->core, "export-source", pw_properties_copy(stream->properties), 0); impl->impl_node = impl_node; @@ -857,6 +859,7 @@ pw_stream_connect(struct pw_stream *stream, struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); int res; + pw_log_debug("stream %p: connect", stream); impl->direction = direction == PW_DIRECTION_INPUT ? SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT; impl->flags = flags; @@ -890,6 +893,7 @@ int pw_stream_disconnect(struct pw_stream *stream) { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); + pw_log_debug("stream %p: disconnect", stream); impl->disconnecting = true; if (impl->node) {