]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix compile issue for PID file stuff when no systemd/launchd/upstart is
authorMichael Sweet <michael.r.sweet@gmail.com>
Sun, 27 Aug 2017 14:59:38 +0000 (10:59 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Sun, 27 Aug 2017 14:59:38 +0000 (10:59 -0400)
available.

Also restructure code slightly so it isn't so convoluted.

scheduler/main.c

index 49b7f18bcc39e70671909789710747471b6067f4..c13d64520e6f1374cafdd2081bc30fae81c826e3 100644 (file)
@@ -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);
-  }
 }