Skip to content

Commit b33e589

Browse files
committed
Make sure the DNS-SD background thread doesn't spin.
1 parent 8d56824 commit b33e589

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎cups/dnssd.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,10 @@ mdns_monitor(cups_dnssd_t *dnssd) // I - DNS-SD context
22232223
break;
22242224

22252225
if (!(polldata.revents & POLLIN))
2226+
{
2227+
usleep(1000);
22262228
continue;
2229+
}
22272230
# endif // !_WIN32
22282231

22292232
if ((error = DNSServiceProcessResult(dnssd->ref)) != kDNSServiceErr_NoError)
@@ -2981,6 +2984,10 @@ avahi_poll_cb(struct pollfd *ufds, // I - File descriptors for poll
29812984
DEBUG_puts("4avahi_poll_cb: Locking mutex.");
29822985
cupsMutexLock(&dnssd->mutex);
29832986

2987+
// Prevent fast loops consuming all CPU...
2988+
if (ret <= 0)
2989+
usleep(1000);
2990+
29842991
return (ret);
29852992
}
29862993

0 commit comments

Comments
 (0)