lib: Add internal fpi_timeout_cancel_all_for_dev()

This will be used to disable all timeouts for a device that's about
to be closed, and freed.
This commit is contained in:
Bastien Nocera 2018-09-27 12:21:45 +02:00
parent de79609550
commit 948a67a51f
2 changed files with 20 additions and 1 deletions

View file

@ -327,7 +327,7 @@ int fpi_img_compare_print_data_to_gallery(struct fp_print_data *print,
struct fp_img *fpi_im_resize(struct fp_img *img, unsigned int w_factor, unsigned int h_factor);
/* polling */
void fpi_timeout_cancel_all_for_dev(struct fp_dev *dev);
void fpi_poll_init(void);
void fpi_poll_exit(void);

View file

@ -477,3 +477,22 @@ void fpi_poll_exit(void)
libusb_set_pollfd_notifiers(fpi_usb_ctx, NULL, NULL, NULL);
}
void
fpi_timeout_cancel_all_for_dev(struct fp_dev *dev)
{
GSList *l;
g_return_if_fail (dev != NULL);
l = active_timers;
while (l) {
struct fpi_timeout *timeout = l->data;
GSList *current = l;
l = l->next;
if (timeout->dev == dev) {
g_free (timeout);
active_timers = g_slist_delete_link (active_timers, current);
}
}
}