From 2d4febaba133aea84b05fe5d5c80833f35b7d5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 11 Nov 2021 12:39:49 +0100 Subject: [PATCH] pulse-server: client: do not drop partially sent messages If the first message has already been partially sent, do not drop it when looking for redundant messages. --- src/modules/module-protocol-pulse/client.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/modules/module-protocol-pulse/client.c b/src/modules/module-protocol-pulse/client.c index 0b74cad32..d64803d67 100644 --- a/src/modules/module-protocol-pulse/client.c +++ b/src/modules/module-protocol-pulse/client.c @@ -292,11 +292,13 @@ int client_flush_messages(struct client *client) static bool client_prune_subscribe_events(struct client *client, uint32_t mask, uint32_t event, uint32_t id) { struct impl *impl = client->impl; - struct message *m, *t; + struct message *m, *t, *first; if ((event & SUBSCRIPTION_EVENT_TYPE_MASK) == SUBSCRIPTION_EVENT_NEW) return false; + first = spa_list_first(&client->out_messages, struct message, link); + spa_list_for_each_safe_reverse(m, t, &client->out_messages, link) { if (m->extra[0] != COMMAND_SUBSCRIBE_EVENT) continue; @@ -309,9 +311,12 @@ static bool client_prune_subscribe_events(struct client *client, uint32_t mask, /* This object is being removed, hence there is * point in keeping the old events regarding * entry in the queue. */ - message_free(impl, m, true, false); - pw_log_debug("client %p: dropped redundant event due to remove event", client); - continue; + + /* if the first message has already been partially sent, do not drop it */ + if (m != first || client->out_index == 0) { + message_free(impl, m, true, false); + pw_log_debug("client %p: dropped redundant event due to remove event", client); + } } if ((event & SUBSCRIPTION_EVENT_TYPE_MASK) == SUBSCRIPTION_EVENT_CHANGE) {