]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/sysman.c
Stop advertising the HTTP methods that are supported (Issue #5540)
[thirdparty/cups.git] / scheduler / sysman.c
index 9f0319a62720badd49d6a3905cc10b568e5e55b6..56eb4e32a057e458aeb0f20eddc9538a6ccb6e97 100644 (file)
@@ -1,14 +1,10 @@
 /*
  * System management functions for the CUPS scheduler.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2018 by Apple Inc.
  * Copyright 2006 by Easy Software Products.
  *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 
@@ -18,7 +14,6 @@
 
 #include "cupsd.h"
 #ifdef __APPLE__
-#  include <vproc.h>
 #  include <IOKit/pwr_mgt/IOPMLib.h>
 #endif /* __APPLE__ */
 
  * and state files to minimize the number of times the disk has to spin
  * up or flash to be written to.
  *
- * Power management support is currently only implemented on OS X, but
+ * Power management support is currently only implemented on macOS, but
  * essentially we use four functions to let the OS know when it is OK to
  * put the system to sleep, typically when we are not in the middle of
- * printing a job.  And on OS X we can also "sleep print" - basically the
+ * printing a job.  And on macOS we can also "sleep print" - basically the
  * system only wakes up long enough to service network requests and process
  * print jobs.
  */
@@ -75,7 +70,7 @@ cupsdCleanDirty(void)
   DirtyFiles     = CUPSD_DIRTY_NONE;
   DirtyCleanTime = 0;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
@@ -101,7 +96,7 @@ cupsdMarkDirty(int what)             /* I - What file(s) are dirty? */
   if (!DirtyCleanTime)
     DirtyCleanTime = time(NULL) + DirtyCleanInterval;
 
-  cupsdSetBusyState();
+  cupsdSetBusyState(0);
 }
 
 
@@ -110,7 +105,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 */
@@ -129,7 +124,6 @@ cupsdSetBusyState(void)
     "Active clients, printing jobs, and dirty files"
   };
 #ifdef __APPLE__
-  static vproc_transaction_t vtran = 0;        /* Current busy transaction */
   static IOPMAssertionID keep_awake = 0;/* Keep the system awake while printing */
 #endif /* __APPLE__ */
 
@@ -139,7 +133,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;
@@ -168,20 +162,8 @@ cupsdSetBusyState(void)
   */
 
   if (newbusy != busy)
-  {
     busy = newbusy;
 
-#ifdef __APPLE__
-    if (busy && !vtran)
-      vtran = vproc_transaction_begin(NULL);
-    else if (!busy && vtran)
-    {
-      vproc_transaction_end(NULL, vtran);
-      vtran = 0;
-    }
-#endif /* __APPLE__ */
-  }
-
 #ifdef __APPLE__
   if (cupsArrayCount(PrintingJobs) > 0 && !keep_awake)
   {
@@ -350,7 +332,7 @@ cupsdStartSystemMonitor(void)
 
   pthread_mutex_init(&SysEventThreadMutex, NULL);
   pthread_cond_init(&SysEventThreadCond, NULL);
-  pthread_create(&SysEventThread, NULL, (void *(*)())sysEventThreadEntry, NULL);
+  pthread_create(&SysEventThread, NULL, (void *(*)(void *))sysEventThreadEntry, NULL);
 
  /*
   * Monitor for power source changes via dispatch queue...
@@ -454,9 +436,6 @@ sysEventThreadEntry(void)
     powerRLS = IONotificationPortGetRunLoopSource(powerNotifierPort);
     CFRunLoopAddSource(CFRunLoopGetCurrent(), powerRLS, kCFRunLoopDefaultMode);
   }
-  else
-    DEBUG_puts("sysEventThreadEntry: error registering for system power "
-               "notifications");
 
  /*
   * Register for system configuration change notifications
@@ -541,17 +520,8 @@ sysEventThreadEntry(void)
        CFRunLoopAddSource(CFRunLoopGetCurrent(), storeRLS,
                           kCFRunLoopDefaultMode);
       }
-      else
-       DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreateRunLoopSource "
-                     "failed: %s\n", SCErrorString(SCError())));
     }
-    else
-      DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreSetNotificationKeys "
-                    "failed: %s\n", SCErrorString(SCError())));
   }
-  else
-    DEBUG_printf(("sysEventThreadEntry: SCDynamicStoreCreate failed: %s\n",
-                  SCErrorString(SCError())));
 
   if (keys)
     CFRelease(keys);