/*
* Main loop for the CUPS scheduler.
*
- * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
strlcpy(filename, ConfigurationFile, len);
if ((slash = strrchr(filename, '/')) == NULL)
{
+ free(filename);
_cupsLangPrintf(stderr,
_("cupsd: Unable to get path to "
"cups-files.conf file."));
#ifdef HAVE_ONDEMAND
if (OnDemand)
+ {
+# ifndef HAVE_SYSTEMD /* Issue #5640: systemd doesn't actually support launch-on-demand services, need to fake it */
+ stop_scheduler = 1;
+# endif /* HAVE_SYSTEMD */
break;
+ }
#endif /* HAVE_ONDEMAND */
DoingShutdown = 1;
if (current_time > expire_time)
{
- if (cupsArrayCount(Subscriptions) > 0)
- cupsdExpireSubscriptions(NULL, NULL);
+ cupsdExpireSubscriptions(NULL, NULL);
cupsdUnloadCompletedJobs();
}
#endif /* !HAVE_AUTHORIZATION_H */
+ /*
+ * Clean job history...
+ */
+
+ if (JobHistoryUpdate && current_time >= JobHistoryUpdate)
+ cupsdCleanJobs();
+
+ /*
+ * Update any pending multi-file documents...
+ */
+
+ if ((current_time - senddoc_time) >= 10)
+ {
+ cupsdCheckJobs();
+ senddoc_time = current_time;
+ }
+
/*
* Check for new data on the client sockets...
*/
}
}
- /*
- * Update any pending multi-file documents...
- */
-
- if ((current_time - senddoc_time) >= 10)
- {
- cupsdCheckJobs();
- senddoc_time = current_time;
- }
-
- /*
- * Clean job history...
- */
-
- if (JobHistoryUpdate && current_time >= JobHistoryUpdate)
- cupsdCleanJobs();
-
/*
* Log statistics at most once a minute when in debug mode...
*/
time_t now; /* Current time */
cupsd_client_t *con; /* Client information */
cupsd_job_t *job; /* Job information */
- cupsd_printer_t *printer; /* Printer information */
const char *why; /* Debugging aid */
* Check for any job activity...
*/
- if (JobHistoryUpdate && timeout > JobHistoryUpdate)
- {
- timeout = JobHistoryUpdate;
- why = "update job history";
- }
-
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
}
}
- /*
- * Check for temporary printers that need to be deleted...
- */
-
- for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers); printer; printer = (cupsd_printer_t *)cupsArrayNext(Printers))
- {
- if (printer->temporary && !printer->job && (!local_timeout || local_timeout > (printer->state_time + 60)))
- local_timeout = printer->state_time + 60;
- }
-
- if (timeout > local_timeout && local_timeout)
- {
- timeout = local_timeout;
- why = "delete stale local printers";
- }
-
/*
* Adjust from absolute to relative time. We add 1 second to the timeout since
* events occur after the timeout expires, and limit the timeout to 86400
#ifdef HAVE_ONDEMAND
if (OnDemand)
{
+ int shared_printers = 0; /* Do we have shared printers? */
+
strlcpy(pidfile, CUPS_KEEPALIVE, sizeof(pidfile));
+ /*
+ * If printer sharing is on see if there are any actual shared printers...
+ */
+
+ if (Browsing && BrowseLocalProtocols)
+ {
+ cupsd_printer_t *p = NULL; /* Current printer */
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ {
+ if (p->shared)
+ break;
+ }
+
+ shared_printers = (p != NULL);
+ }
+
if (cupsArrayCount(ActiveJobs) || /* Active jobs */
WebInterface || /* Web interface enabled */
NeedReload || /* Doing a reload */
- (Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)))
- /* Printers being shared */
+ shared_printers) /* Printers being shared */
{
/*
* Create or remove the "keep-alive" file based on whether there are active