From f31f1edde25d554890abdc4794fbebb16a0a0930 Mon Sep 17 00:00:00 2001
From: Christoph Haag <christoph.haag@collabora.com>
Date: Fri, 19 Jun 2020 14:41:34 +0200
Subject: [PATCH] ipc: Set destroyed swapchains to not active

Fixes the service failing to create swapchains with "ERROR: Too many swapchains!"
after one or several sequentially started and quit clients created 32 swapchains.
---
 src/xrt/ipc/ipc_server_client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/xrt/ipc/ipc_server_client.c b/src/xrt/ipc/ipc_server_client.c
index 601121369..7fc7bd171 100644
--- a/src/xrt/ipc/ipc_server_client.c
+++ b/src/xrt/ipc/ipc_server_client.c
@@ -160,6 +160,8 @@ ipc_handle_swapchain_create(volatile struct ipc_client_state *cs,
 
 	uint32_t num_images = xsc->num_images;
 
+	IPC_SPEW(cs->server, "IPC: Created swapchain %d\n", index);
+
 	cs->xscs[index] = xsc;
 	cs->swapchain_data[index].active = true;
 	cs->swapchain_data[index].width = width;
@@ -448,6 +450,8 @@ client_loop(volatile struct ipc_client_state *cs)
 	// Destroy all swapchains now.
 	for (uint32_t j = 0; j < IPC_MAX_CLIENT_SWAPCHAINS; j++) {
 		xrt_swapchain_destroy((struct xrt_swapchain **)&cs->xscs[j]);
+		cs->swapchain_data[j].active = false;
+		IPC_SPEW(cs->server, "IPC: Destroyed swapchain %d\n", j);
 	}
 
 	// Should we stop the server when a client disconnects?
-- 
GitLab