* dnssdRegisterCallback() - DNSServiceRegister callback.
* dnssdRegisterPrinter() - Start sending broadcast information for a
* printer or update the broadcast contents.
+ * dnssdStop() - Stop all DNS-SD registrations.
* dnssdUpdate() - Handle DNS-SD queries.
* get_hostconfig() - Get an /etc/hostconfig service setting.
* is_local_queue() - Determine whether the URI points at a local
const char *name, const char *regtype,
const char *domain, void *context);
static void dnssdRegisterPrinter(cupsd_printer_t *p);
+static void dnssdStop(void);
static void dnssdUpdate(void);
#endif /* HAVE_DNSSD */
#ifdef HAVE_DNSSD
if ((BrowseLocalProtocols & BROWSE_DNSSD) && DNSSDRef)
- {
- if (WebIFRef)
- {
- DNSServiceRefDeallocate(WebIFRef);
- WebIFRef = NULL;
- }
-
- if (RemoteRef)
- {
- DNSServiceRefDeallocate(RemoteRef);
- RemoteRef = NULL;
- }
-
- cupsdRemoveSelect(DNSServiceRefSockFD(DNSSDRef));
-
- DNSServiceRefDeallocate(DNSSDRef);
- DNSSDRef = NULL;
-
- cupsArrayDelete(DNSSDPrinters);
- DNSSDPrinters = NULL;
-
- DNSSDPort = 0;
- }
+ dnssdStop();
#endif /* HAVE_DNSSD */
#ifdef HAVE_LIBSLP
}
+/*
+ * 'dnssdStop()' - Stop all DNS-SD registrations.
+ */
+
+static void
+dnssdStop(void)
+{
+ cupsd_printer_t *p; /* Current printer */
+
+
+ /*
+ * De-register the individual printers
+ */
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ p;
+ p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ dnssdDeregisterPrinter(p);
+
+ /*
+ * Shutdown the rest of the service refs...
+ */
+
+ if (WebIFRef)
+ {
+ DNSServiceRefDeallocate(WebIFRef);
+ WebIFRef = NULL;
+ }
+
+ if (RemoteRef)
+ {
+ DNSServiceRefDeallocate(RemoteRef);
+ RemoteRef = NULL;
+ }
+
+ cupsdRemoveSelect(DNSServiceRefSockFD(DNSSDRef));
+
+ DNSServiceRefDeallocate(DNSSDRef);
+ DNSSDRef = NULL;
+
+ cupsArrayDelete(DNSSDPrinters);
+ DNSSDPrinters = NULL;
+
+ DNSSDPort = 0;
+}
+
+
/*
* 'dnssdUpdate()' - Handle DNS-SD queries.
*/
if ((sdErr = DNSServiceProcessResult(DNSSDRef)) != kDNSServiceErr_NoError)
+ {
cupsdLogMessage(CUPSD_LOG_ERROR,
"DNS Service Discovery registration error %d!",
sdErr);
+ dnssdStop();
+ }
}
#endif /* HAVE_DNSSD */
else
len = strlen(p->name);
+ if (len >= sizeof(name))
+ {
+ /*
+ * If the printer name length somehow is greater than we normally allow,
+ * skip this printer...
+ */
+
+ len = 0;
+ cupsArrayRestore(Printers);
+ continue;
+ }
+
strncpy(name, p->name, len);
name[len] = '\0';
offset = 0;
while ((ptr = cupsdStatBufUpdate(PollStatusBuffer, &loglevel,
message, sizeof(message))) != NULL)
+ {
+ if (loglevel == CUPSD_LOG_INFO)
+ cupsdLogMessage(CUPSD_LOG_INFO, "%s", message);
+
if (!strchr(PollStatusBuffer->buffer, '\n'))
break;
+ }
if (ptr == NULL && !PollStatusBuffer->bufused)
{