client: remove busy state from client in resource destroy

When a resource is doing an operation that sets the client in the busy
state, make sure we unblock the client again when the resource is
destroyed before we could complete the operation or else the client
is stuck forever.
This commit is contained in:
Wim Taymans 2020-06-09 10:57:15 +02:00
parent 8f251fc7d4
commit 62dd58a604
3 changed files with 74 additions and 22 deletions

View file

@ -112,19 +112,31 @@ static const struct pw_resource_events resource_events = {
.destroy = global_unbind,
};
static void impl_resource_pong(void *data, int seq)
static void remove_pending(struct resource_data *d)
{
struct resource_data *d = data;
if (d->pong_seq == seq) {
if (d->pong_seq != 0) {
pw_impl_client_set_busy(pw_resource_get_client(d->resource), false);
d->pong_seq = 0;
d->impl->pending--;
}
}
static void impl_resource_destroy(void *data)
{
struct resource_data *d = data;
remove_pending(d);
}
static void impl_resource_pong(void *data, int seq)
{
struct resource_data *d = data;
if (d->pong_seq == seq)
remove_pending(d);
}
static const struct pw_resource_events impl_resource_events = {
PW_VERSION_RESOURCE_EVENTS,
.destroy = impl_resource_destroy,
.pong = impl_resource_pong,
};