From: Zdenek Dohnal Date: Thu, 4 Jan 2024 12:33:04 +0000 (+0100) Subject: dest.c: Fix infinite loop in `cups_enum_dests()` X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=add9975420368b7c89591b06b3d2081a5418fdb5;p=thirdparty%2Fcups.git dest.c: Fix infinite loop in `cups_enum_dests()` Update remaining time after `usleep()`, otherwise there is no difference in elapsed time, so `remaining` will never be less or equal to 0. Fixes CI on Linux --- diff --git a/cups/dest.c b/cups/dest.c index c528fdf219..2dc8a937bd 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -3229,8 +3229,6 @@ cups_enum_dests( goto enum_finished; // Get DNS-SD printers... - gettimeofday(&curtime, NULL); - if ((dnssd = cupsDNSSDNew(dnssd_error_cb, NULL)) == NULL) { DEBUG_puts("1cups_enum_dests: Unable to create service browser, returning 0."); @@ -3268,15 +3266,13 @@ cups_enum_dests( else remaining = msec; + gettimeofday(&curtime, NULL); + while (remaining > 0 && (!cancel || !*cancel)) { // Check for input... DEBUG_printf("1cups_enum_dests: remaining=%d", remaining); - cups_elapsed(&curtime); - - remaining -= cups_elapsed(&curtime); - cupsRWLockRead(&data.rwlock); for (i = 0, num_devices = cupsArrayCount(data.devices), count = 0, completed = 0; i < num_devices; i ++) @@ -3369,6 +3365,8 @@ cups_enum_dests( break; usleep(100000); + + remaining -= cups_elapsed(&curtime); } // Return...