From: Michael Sweet Date: Sun, 27 Aug 2017 14:59:38 +0000 (-0400) Subject: Fix compile issue for PID file stuff when no systemd/launchd/upstart is X-Git-Tag: v2.2.5~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9b2d701dae26930a356408ada2c4f7eacc59100;p=thirdparty%2Fcups.git Fix compile issue for PID file stuff when no systemd/launchd/upstart is available. Also restructure code slightly so it isn't so convoluted. --- diff --git a/scheduler/main.c b/scheduler/main.c index 49b7f18bcc..c13d64520e 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -2019,8 +2019,8 @@ service_checkin(void) static void service_checkout(int shutdown) /* I - Shutting down? */ { - cups_file_t *fp; /* File */ - char pidfile[1024]; /* PID/KeepAlive file */ + cups_file_t *fp; /* File */ + char pidfile[1024]; /* PID/KeepAlive file */ /* @@ -2030,22 +2030,34 @@ service_checkout(int shutdown) /* I - Shutting down? */ #ifdef HAVE_ONDEMAND if (OnDemand) + { strlcpy(pidfile, CUPS_KEEPALIVE, sizeof(pidfile)); + + if (cupsArrayCount(ActiveJobs) || /* Active jobs */ + WebInterface || /* Web interface enabled */ + NeedReload || /* Doing a reload */ + (Browsing && BrowseLocalProtocols && cupsArrayCount(Printers))) + /* Printers being shared */ + { + /* + * Create or remove the "keep-alive" file based on whether there are active + * jobs or shared printers to advertise... + */ + + shutdown = 0; + } + } else #endif /* HAVE_ONDEMAND */ snprintf(pidfile, sizeof(pidfile), "%s/cupsd.pid", StateDir); - /* - * Create or remove the "keep-alive" file based on whether there are active - * jobs or shared printers to advertise... - */ + if (shutdown) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "Removing KeepAlive/PID file \"%s\".", pidfile); - if (!OnDemand || /* Not running on-demand */ - cupsArrayCount(ActiveJobs) || /* Active jobs */ - WebInterface || /* Web interface enabled */ - NeedReload || /* Doing a reload */ - (Browsing && BrowseLocalProtocols && cupsArrayCount(Printers))) - /* Printers being shared */ + unlink(pidfile); + } + else { cupsdLogMessage(CUPSD_LOG_DEBUG, "Creating KeepAlive/PID file \"%s\".", pidfile); @@ -2061,12 +2073,6 @@ service_checkout(int shutdown) /* I - Shutting down? */ else cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create KeepAlive/PID file \"%s\": %s", pidfile, strerror(errno)); } - else if (shutdown) - { - cupsdLogMessage(CUPSD_LOG_DEBUG, "Removing KeepAlive/PID file \"%s\".", pidfile); - - unlink(pidfile); - } }