Skip to content

Commit

Permalink
Make sure to send device remove events when unregistering the callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed May 22, 2019
1 parent a6b542b commit 8b82ef1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libusbmuxd.c
Expand Up @@ -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);
Expand Down

0 comments on commit 8b82ef1

Please sign in to comment.