pulse-server: Handle overlong writes from clients

When a client writes more then requested, let the requested field go
negative so that it is taken into account the next time we ask for more
data.

Also the requested field follows the difference in the write pointer
caused by seeks.

See #2626
Fixes #2674
This commit is contained in:
Barnabás Pőcze 2022-09-08 09:14:19 +02:00 committed by Wim Taymans
parent d5bc6aa2cb
commit 27211856eb

View file

@ -166,6 +166,7 @@ static int handle_memblock(struct client *client, struct message *msg)
index += diff;
filled += diff;
stream->write_index += diff;
stream->requested -= diff;
if (filled < 0) {
/* underrun, reported on reader side */
@ -182,9 +183,10 @@ static int handle_memblock(struct client *client, struct message *msg)
msg->data,
SPA_MIN(msg->length, MAXLENGTH));
index += msg->length;
stream->write_index += msg->length;
spa_ringbuffer_write_update(&stream->ring, index);
stream->requested -= SPA_MIN(msg->length, stream->requested);
stream->write_index += msg->length;
stream->requested -= msg->length;
stream_send_request(stream);