]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The scheduler did not run with a high enough priority, causing problems on
authorMichael Sweet <michael.r.sweet@gmail.com>
Mon, 2 Oct 2017 23:14:25 +0000 (19:14 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Mon, 2 Oct 2017 23:14:25 +0000 (19:14 -0400)
busy systems (rdar://33789342)

- Change ProcessType to Adaptive for both cupsd and cups-lpd
- Add "working" parameter to cupsdSetBusyState
- Call cupsdSetBusyState on startup to boost the priority on startup.

CHANGES.md
scheduler/client.c
scheduler/cups-lpd.c
scheduler/job.c
scheduler/main.c
scheduler/org.cups.cups-lpd.plist.in
scheduler/org.cups.cupsd.plist
scheduler/server.c
scheduler/sysman.c
scheduler/sysman.h

index 72038fc149eb9ef201b4f63018ceccfefe56cccc..7eb6a862c1f0c5fb5dc28f7666e9ba67e3f0ab81 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES - 2.2.5 - 2017-09-25
+CHANGES - 2.2.5 - 2017-10-02
 ============================
 
 CHANGES IN CUPS V2.2.5
@@ -59,7 +59,8 @@ CHANGES IN CUPS V2.2.5
 - The `ippCopyAttribute` function did not copy out-of-band values correctly
   (rdar://33688003)
 - Fixed the localization fallback code on macOS (rdar://33583699)
-- The `ipptool` program now offers an option to validate response headers.
+- The scheduler did not run with a high enough priority, causing problems on
+  busy systems (rdar://33789342)
 - The `ipptool` program's `-P` option did not work correctly.
 - The `ipptool` program did not compare URI scheme or hostname components
   correctly for the WITH-ALL-HOSTNAMES, WITH-ALL-SCHEMES, WITH-HOSTNAME, or
index 78695ae659957f53ea1e860e8cd14e231792f8e2..d628dc6c3417c7f6b0a53ab473f35c930a4e19f5 100644 (file)
@@ -85,6 +85,8 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
   if (cupsArrayCount(Clients) == MaxClients)
     return;
 
+  cupsdSetBusyState(1);
+
  /*
   * Get a pointer to the next available client...
   */
@@ -439,7 +441,7 @@ cupsdCloseClient(cupsd_client_t *con)       /* I - Client to close */
   if (httpGetFd(con->http) >= 0)
   {
     cupsArrayRemove(ActiveClients, con);
-    cupsdSetBusyState();
+    cupsdSetBusyState(0);
 
 #ifdef HAVE_SSL
    /*
@@ -760,7 +762,7 @@ cupsdReadClient(cupsd_client_t *con)        /* I - Client to read from */
         if (!cupsArrayFind(ActiveClients, con))
        {
          cupsArrayAdd(ActiveClients, con);
-          cupsdSetBusyState();
+          cupsdSetBusyState(0);
         }
 
     case HTTP_STATE_OPTIONS :
@@ -2082,7 +2084,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
     else
     {
       cupsArrayRemove(ActiveClients, con);
-      cupsdSetBusyState();
+      cupsdSetBusyState(0);
     }
   }
 }
@@ -2807,7 +2809,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
     else
     {
       cupsArrayRemove(ActiveClients, con);
-      cupsdSetBusyState();
+      cupsdSetBusyState(0);
     }
   }
 }
index 5d5e6f8944cc10e24c8ee487102e0e9faf93a8bb..fbc69e10294bc088af9db8c1dcc87804ccf9cfa9 100644 (file)
@@ -103,7 +103,6 @@ main(int  argc,                             /* I - Number of command-line arguments */
   xpc_transaction_begin();
 #endif /* __APPLE__ */
 
-
  /*
   * Don't buffer the output...
   */
index 9d281db6b4f15d3d10877f5db63630b88f51bbad..86e75e65ce9bd366f2d60b87538cf05fe61d0025 100644 (file)
@@ -2768,7 +2768,7 @@ cupsdSetJobState(
   * Update the server "busy" state...
   */
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
index 09735b83aceafcfe6722417de616d45af0e90b53..8925c8373336d9a4855ca8e5b0606dc4c6968ef3 100644 (file)
@@ -495,6 +495,12 @@ main(int  argc,                            /* I - Number of command-line args */
     exit(errno);
   }
 
+ /*
+  * Let the system know we are busy while we bring up cupsd...
+  */
+
+  cupsdSetBusyState(1);
+
  /*
   * Set the timezone info...
   */
@@ -683,6 +689,8 @@ main(int  argc,                             /* I - Number of command-line args */
   else
     cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started in background.");
 
+  cupsdSetBusyState(0);
+
  /*
   * Start any pending print jobs...
   */
index 76eb2eefd5ea958525a20582fef60a50a658e40c..0866b1555e350ab4d6e1f00a3baba42597f54261 100644 (file)
@@ -7,7 +7,7 @@
        <key>Label</key>
        <string>org.cups.cups-lpd</string>
        <key>ProcessType</key>
-       <string>Background</string>
+       <string>Adaptive</string>
        <key>EnableTransactions</key>
        <true/>
        <key>EnablePressuredExit</key>
index abc91333c33cce5c601a81149346b308b16391e1..8e1d0e96e5e3de295dfc1f2ee3220669576ed3cb 100644 (file)
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>Label</key>
        <string>org.cups.cupsd</string>
        <key>ProcessType</key>
-       <string>Background</string>
+       <string>Adaptive</string>
        <key>EnableTransactions</key>
        <true/>
        <key>EnablePressuredExit</key>
@@ -25,7 +25,6 @@
                <string>/usr/sbin/cupsd</string>
                <string>-l</string>
        </array>
-       <!-- These environment variables are only used when CUPS is compiled with debug-printfs support -->
        <key>EnvironmentVariables</key>
        <dict>
                <key>CUPS_DEBUG_LOG</key>
index 04b26d64d2d1fd0180c85a74df0da53eb4a8d987..d28cd4a0b6527f239279e33b43ca247d7fcb175b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Server start/stop routines for the CUPS scheduler.
  *
- * Copyright 2007-2012 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -78,7 +78,7 @@ cupsdStartServer(void)
               CUPSD_EVENT_SERVER_STARTED;
   started   = 1;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
index 8b43975d6a5ad1e51cbc0671ae5553302d74f4ce..46eb39a0bc3d24c5431543c242c40a535d70ce89 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * System management functions for the CUPS scheduler.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -75,7 +75,7 @@ cupsdCleanDirty(void)
   DirtyFiles     = CUPSD_DIRTY_NONE;
   DirtyCleanTime = 0;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
@@ -101,7 +101,7 @@ cupsdMarkDirty(int what)            /* I - What file(s) are dirty? */
   if (!DirtyCleanTime)
     DirtyCleanTime = time(NULL) + DirtyCleanInterval;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
@@ -110,7 +110,7 @@ cupsdMarkDirty(int what)            /* I - What file(s) are dirty? */
  */
 
 void
-cupsdSetBusyState(void)
+cupsdSetBusyState(int working)          /* I - Doing significant work? */
 {
   int                  i;              /* Looping var */
   cupsd_job_t          *job;           /* Current job */
@@ -139,7 +139,7 @@ cupsdSetBusyState(void)
   */
 
   newbusy = (DirtyCleanTime ? 1 : 0) |
-           (cupsArrayCount(ActiveClients) ? 4 : 0);
+           ((working || cupsArrayCount(ActiveClients) > 0) ? 4 : 0);
 
   for (job = (cupsd_job_t *)cupsArrayFirst(PrintingJobs);
        job;
index 929ee73589c7e4dbaba54b8e5a6fab1682da172a..74c667b0d36ff743b1ff5b704c054634f4e428f9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * System management definitions for the CUPS scheduler.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 2006 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -54,6 +54,6 @@ VAR int                       SysEventPipes[2] VALUE2(-1,-1);
 extern void    cupsdAllowSleep(void);
 extern void    cupsdCleanDirty(void);
 extern void    cupsdMarkDirty(int what);
-extern void    cupsdSetBusyState(void);
+extern void    cupsdSetBusyState(int working);
 extern void    cupsdStartSystemMonitor(void);
 extern void    cupsdStopSystemMonitor(void);