From 451875e2878061a80a7de3698895e841744a78c6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Aug 2020 10:41:58 +1000 Subject: [PATCH] libei: if we get disconnected after ei_device_add(), queue a removed event If we get disconnected after calling ei_device_add() but before EIS saw and processed the event, we need to emulate a removed event ourselves. Signed-off-by: Peter Hutterer --- src/libei.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libei.c b/src/libei.c index dc591b0..9526f1e 100644 --- a/src/libei.c +++ b/src/libei.c @@ -302,6 +302,9 @@ ei_remove_device(struct ei_device *device) struct ei *ei = ei_device_get_context(device); int rc = connection_send_remove(ei, device); + if (ei->state == EI_STATE_DISCONNECTING) + ei_queue_removed_event(device); + list_remove(&device->link); ei_device_unref(device);