Skip to content

Commit

Permalink
Fix CI for CUPS 2.5
Browse files Browse the repository at this point in the history
Fixing deadlock and infinite loop in `cups_enum_dests()` - more info in specific commits.
  • Loading branch information
zdohnal authored Jan 5, 2024
2 parents d1a3f22 + 78a051b commit cbfa37b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions cups/dest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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 ++)
Expand Down Expand Up @@ -3369,6 +3365,8 @@ cups_enum_dests(
break;

usleep(100000);

remaining -= cups_elapsed(&curtime);
}

// Return...
Expand Down
3 changes: 2 additions & 1 deletion cups/dnssd.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ cupsDNSSDDelete(cups_dnssd_t *dnssd) // I - DNS-SD context
cupsArrayDelete(dnssd->resolves);
cupsArrayDelete(dnssd->services);

cupsMutexUnlock(&dnssd->mutex);

#ifdef HAVE_MDNSRESPONDER
cupsThreadCancel(dnssd->monitor);
cupsThreadWait(dnssd->monitor);
Expand All @@ -447,7 +449,6 @@ cupsDNSSDDelete(cups_dnssd_t *dnssd) // I - DNS-SD context
avahi_simple_poll_free(dnssd->poll);
#endif // HAVE_MDNSRESPONDER

cupsMutexUnlock(&dnssd->mutex);
cupsMutexDestroy(&dnssd->mutex);
free(dnssd);
}
Expand Down

0 comments on commit cbfa37b

Please sign in to comment.