]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The scheduler did not always idle exit as quickly as it could...
authorMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 21 Feb 2019 16:04:14 +0000 (11:04 -0500)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 21 Feb 2019 16:04:14 +0000 (11:04 -0500)
CHANGES.md
scheduler/main.c
scheduler/server.c
scheduler/subscriptions.c

index c66ca2054c4125aa6126c33c8153b1ddd748983c..57bd5f85c0563852fb4dfccb5d3a2a8b29be54c3 100644 (file)
@@ -29,6 +29,7 @@ Changes in CUPS v2.2.11
   names for the server when using GNU TLS (Issue #5525)
 - Fixed a potential crash bug in cups-driverd (rdar://46625579)
 - Fixed a performance regression with large PPDs (rdar://47040759)
+- The scheduler did not always idle exit as quickly as it could.
 
 
 Changes in CUPS v2.2.10
index a61592cd82bac3235c739667e82f8f671728a1a5..e96337086f405cf43995e1d1192aa0c7ebf577a1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
  *
  * These coded instructions, statements, and computer programs are the
@@ -807,15 +807,26 @@ main(int  argc,                           /* I - Number of command-line args */
     * inactivity...
     */
 
-    if (timeout == 86400 && OnDemand && IdleExitTimeout &&
-        !cupsArrayCount(ActiveJobs) &&
+    if (OnDemand && IdleExitTimeout &&
 #  ifdef HAVE_SYSTEMD
         !WebInterface &&
 #  endif /* HAVE_SYSTEMD */
-       (!Browsing || !BrowseLocalProtocols || !cupsArrayCount(Printers)))
+        !cupsArrayCount(ActiveJobs))
     {
-      timeout          = IdleExitTimeout;
-      service_idle_exit = 1;
+      cupsd_printer_t *p = NULL;       /* Current printer */
+
+      if (Browsing && BrowseLocalProtocols)
+      {
+        for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers))
+          if (p->shared)
+            break;
+      }
+
+      if (!p)
+      {
+       timeout           = IdleExitTimeout;
+       service_idle_exit = 1;
+      }
     }
     else
       service_idle_exit = 0;
@@ -946,8 +957,7 @@ main(int  argc,                             /* I - Number of command-line args */
 
     if (current_time > expire_time)
     {
-      if (cupsArrayCount(Subscriptions) > 0)
-        cupsdExpireSubscriptions(NULL, NULL);
+      cupsdExpireSubscriptions(NULL, NULL);
 
       cupsdUnloadCompletedJobs();
 
index 63fcf90bf5be12f2510c49f7b5c6f8f08748f308..4714a61503fdb04c6506177d12d2d523fac7711f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Server start/stop routines for the CUPS scheduler.
  *
- * Copyright 2007-2018 by Apple Inc.
+ * Copyright 2007-2019 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -176,6 +176,15 @@ cupsdStopServer(void)
   cupsdDestroyProfile(DefaultProfile);
   DefaultProfile = NULL;
 
+ /*
+  * Expire subscriptions and clean out old jobs...
+  */
+
+  cupsdExpireSubscriptions(NULL, NULL);
+
+  if (JobHistoryUpdate)
+    cupsdCleanJobs();
+
  /*
   * Write out any dirty files...
   */
index b2abf14ee9c14baa52c0209b0dcd00f798d8f827..cac340520d9d02a9263baf21fb92162dc43f7d5a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Subscription routines for the CUPS scheduler.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2019 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -652,6 +652,9 @@ cupsdExpireSubscriptions(
   time_t               curtime;        /* Current time */
 
 
+  if (cupsArrayCount(Subscriptions) == 0)
+    return;
+
   curtime = time(NULL);
   update  = 0;