From 8b82ef166eb2ac12bc5228cf06a883ec86d520ca Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Thu, 23 May 2019 01:16:29 +0200 Subject: Make sure to send device remove events when unregistering the callback --- src/libusbmuxd.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c index 340d75a..d971f14 100644 --- a/src/libusbmuxd.c +++ b/src/libusbmuxd.c @@ -1155,6 +1155,14 @@ USBMUXD_API int usbmuxd_events_unsubscribe(usbmuxd_subscription_context_t ctx) mutex_lock(&listener_mutex); if (collection_remove(&listeners, ctx) == 0) { + FOREACH(usbmuxd_device_info_t *dev, &devices) { + if (dev) { + usbmuxd_event_t ev; + ev.event = UE_DEVICE_REMOVE; + memcpy(&ev.device, dev, sizeof(usbmuxd_device_info_t)); + (ctx)->callback(&ev, (ctx)->user_data); + } + } ENDFOREACH free(ctx); } num = collection_count(&listeners); -- cgit v1.1-32-gdbae