From: msweet Date: Sat, 30 Aug 2014 01:51:22 +0000 (+0000) Subject: Re-introduce dark wake support, but this time while monitoring the current X-Git-Tag: v2.2b1~488 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1deb86fdaf8ca1e9bee08b0218b355bac6a9447d;p=thirdparty%2Fcups.git Re-introduce dark wake support, but this time while monitoring the current power source () This allows printing to work while the system is visibly asleep. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12140 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES.txt b/CHANGES.txt index 57e1e020fe..e59a94d3e7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,11 @@ -CHANGES.txt - 2.0rc1 - 2014-08-28 +CHANGES.txt - 2.0rc1 - 2014-08-29 --------------------------------- CHANGES IN CUPS V2.0rc1 - Documentation updates (STR #4464) + - The scheduler now monitors the AC power status on OS X, allowing for + "sleep printing" when sharing printers () - The scheduler incorrectly called launch_activate_socket multiple times on OS X () - The ippserver test program now passes the IPP Everywhere self- diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index c01523b979..ec98d4eb09 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -369,9 +369,6 @@ case $uname in AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H)) AC_CHECK_FUNCS(mbr_uid_to_uuid) - dnl Check for the vproc_transaction_begin/end stuff... - AC_CHECK_FUNCS(vproc_transaction_begin) - dnl Need header... AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H)) diff --git a/config.h.in b/config.h.in index a6c62b8e14..5937ac3c27 100644 --- a/config.h.in +++ b/config.h.in @@ -637,13 +637,6 @@ #endif /* HAVE_ARC4RANDOM */ -/* - * Do we have vproc_transaction_begin/end? - */ - -#undef HAVE_VPROC_TRANSACTION_BEGIN - - /* * Do we have libusb? */ diff --git a/doc/help/man-ipptool.html b/doc/help/man-ipptool.html index fc6ac1b702..aba14e5510 100644 --- a/doc/help/man-ipptool.html +++ b/doc/help/man-ipptool.html @@ -71,9 +71,12 @@ ipptool - perform internet printing protocol requests ipptool sends IPP requests to the specified printer-uri -and tests and/or displays the results. Each named +and tests and/or displays the results. +Each named testfile -defines one or more requests, including the expected response status, attributes, and values. Output is either a plain text, formatted text, CSV, or XML report on the standard output, with a non-zero exit status indicating that one or more tests have failed. The +defines one or more requests, including the expected response status, attributes, and values. +Output is either a plain text, formatted text, CSV, or XML report on the standard output, with a non-zero exit status indicating that one or more tests have failed. +The testfile format is described in ipptoolfile(5). @@ -102,7 +105,8 @@ must connect to the printer or server using IPv4. ipptool must connect to the printer or server using IPv6.
-C -
Specifies that requests should be sent using the HTTP/1.1 "Transfer-Encoding: chunked" header, which is required for conformance by all versions of IPP. The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files. +
Specifies that requests should be sent using the HTTP/1.1 "Transfer-Encoding: chunked" header, which is required for conformance by all versions of IPP. +The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files.
-E
Forces TLS encryption when connecting to the server using the HTTP "Upgrade" header.
-I @@ -110,9 +114,11 @@ must connect to the printer or server using IPv6. ipptool will continue past errors.
-L -
Specifies that requests should be sent using the HTTP/1.0 "Content-Length:" header, which is required for conformance by all versions of IPP. The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files. +
Specifies that requests should be sent using the HTTP/1.0 "Content-Length:" header, which is required for conformance by all versions of IPP. +The default is to use "Transfer-Encoding: chunked" for requests with attached files and "Content-Length:" for requests without attached files.
-P filename.plist -
Specifies that the test results should be written to the named XML (Apple plist) file in addition to the plain text report. This option is incompatible with the -i (interval) and -n (repeat-count) options. +
Specifies that the test results should be written to the named XML (Apple plist) file in addition to the regular test report (-t). +This option is incompatible with the -i (interval) and -n (repeat-count) options.
-S
Forces (dedicated) TLS encryption when connecting to the server.
-T seconds @@ -120,7 +126,8 @@ will continue past errors.
-V version
Specifies the default IPP version to use: 1.0, 1.1, 2.0, 2.1, or 2.2. If not specified, version 1.1 is used.
-X -
Specifies that XML (Apple plist) output is desired instead of the plain text report. This option is incompatible with the -i (interval) and -n (repeat-count) options. +
Specifies that XML (Apple plist) output is desired instead of the plain text report. +This option is incompatible with the -i (interval) and -n (repeat-count) options.
-c
Specifies that CSV (comma-separated values) output is desired instead of the plain text output.
-d name=value @@ -130,17 +137,22 @@ will continue past errors.
-i seconds
Specifies that the (last) testfile -should be repeated at the specified interval. This option is incompatible with the -X (XML plist output) option. +should be repeated at the specified interval. +This option is incompatible with the -X (XML plist output) option.
-l
Specifies that plain text output is desired.
-n repeat-count
Specifies that the (last) testfile -should be repeated the specified number of times. This option is incompatible with the -X (XML plist output) option. +should be repeated the specified number of times. +This option is incompatible with the -X (XML plist output) option. +
-q +
Be quiet and produce no output.
-t
Specifies that CUPS test report output is desired instead of the plain text output.
-v -
Specifies that all request and response attributes should be output in CUPS test mode (-t). This is the default for XML output. +
Specifies that all request and response attributes should be output in CUPS test mode (-t). +This is the default for XML output.

Exit Status

The diff --git a/man/ipptool.man b/man/ipptool.man index d5397a59dc..9fa9f05d45 100644 --- a/man/ipptool.man +++ b/man/ipptool.man @@ -11,7 +11,7 @@ .\" 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/". .\" -.TH ipptool 1 "CUPS" "15 May 2014" "Apple Inc." +.TH ipptool 1 "CUPS" "29 August 2014" "Apple Inc." .SH NAME ipptool \- perform internet printing protocol requests .SH SYNOPSIS @@ -76,9 +76,12 @@ ipptool \- perform internet printing protocol requests .B ipptool sends IPP requests to the specified .I printer-uri -and tests and/or displays the results. Each named +and tests and/or displays the results. +Each named .I testfile -defines one or more requests, including the expected response status, attributes, and values. Output is either a plain text, formatted text, CSV, or XML report on the standard output, with a non-zero exit status indicating that one or more tests have failed. The +defines one or more requests, including the expected response status, attributes, and values. +Output is either a plain text, formatted text, CSV, or XML report on the standard output, with a non-zero exit status indicating that one or more tests have failed. +The .I testfile format is described in .BR ipptoolfile (5). @@ -112,7 +115,8 @@ Specifies that must connect to the printer or server using IPv6. .TP 5 .B \-C -Specifies that requests should be sent using the HTTP/1.1 "Transfer\-Encoding: chunked" header, which is required for conformance by all versions of IPP. The default is to use "Transfer\-Encoding: chunked" for requests with attached files and "Content\-Length:" for requests without attached files. +Specifies that requests should be sent using the HTTP/1.1 "Transfer\-Encoding: chunked" header, which is required for conformance by all versions of IPP. +The default is to use "Transfer\-Encoding: chunked" for requests with attached files and "Content\-Length:" for requests without attached files. .TP 5 .B \-E Forces TLS encryption when connecting to the server using the HTTP "Upgrade" header. @@ -123,10 +127,12 @@ Specifies that will continue past errors. .TP 5 .B \-L -Specifies that requests should be sent using the HTTP/1.0 "Content\-Length:" header, which is required for conformance by all versions of IPP. The default is to use "Transfer\-Encoding: chunked" for requests with attached files and "Content\-Length:" for requests without attached files. +Specifies that requests should be sent using the HTTP/1.0 "Content\-Length:" header, which is required for conformance by all versions of IPP. +The default is to use "Transfer\-Encoding: chunked" for requests with attached files and "Content\-Length:" for requests without attached files. .TP 5 .BI \-P \ filename.plist -Specifies that the test results should be written to the named XML (Apple plist) file in addition to the plain text report. This option is incompatible with the \fB\-i\fR (interval) and \fB\-n\fR (repeat\-count) options. +Specifies that the test results should be written to the named XML (Apple plist) file in addition to the regular test report (\fB\-t\fR). +This option is incompatible with the \fB\-i\fR (interval) and \fB\-n\fR (repeat\-count) options. .TP 5 .B \-S Forces (dedicated) TLS encryption when connecting to the server. @@ -138,7 +144,8 @@ Specifies a timeout for IPP requests in seconds. Specifies the default IPP version to use: 1.0, 1.1, 2.0, 2.1, or 2.2. If not specified, version 1.1 is used. .TP 5 .B \-X -Specifies that XML (Apple plist) output is desired instead of the plain text report. This option is incompatible with the \fB\-i\fR (interval) and \fB\-n\fR (repeat\-count) options. +Specifies that XML (Apple plist) output is desired instead of the plain text report. +This option is incompatible with the \fB\-i\fR (interval) and \fB\-n\fR (repeat\-count) options. .TP 5 .B \-c Specifies that CSV (comma\-separated values) output is desired instead of the plain text output. @@ -152,7 +159,8 @@ Defines the default request filename for tests. .BI \-i \ seconds Specifies that the (last) .I testfile -should be repeated at the specified interval. This option is incompatible with the \fB\-X\fR (XML plist output) option. +should be repeated at the specified interval. +This option is incompatible with the \fB\-X\fR (XML plist output) option. .TP 5 .B \-l Specifies that plain text output is desired. @@ -160,13 +168,18 @@ Specifies that plain text output is desired. .BI \-n \ repeat\-count Specifies that the (last) .I testfile -should be repeated the specified number of times. This option is incompatible with the \fI\-X\fR (XML plist output) option. +should be repeated the specified number of times. +This option is incompatible with the \fI\-X\fR (XML plist output) option. +.TP 5 +.B \-q +Be quiet and produce no output. .TP 5 .B \-t Specifies that CUPS test report output is desired instead of the plain text output. .TP 5 .B \-v -Specifies that all request and response attributes should be output in CUPS test mode (\fB\-t\fR). This is the default for XML output. +Specifies that all request and response attributes should be output in CUPS test mode (\fB\-t\fR). +This is the default for XML output. .SH EXIT STATUS The .B ipptool diff --git a/scheduler/job.c b/scheduler/job.c index 9d500d1fbf..0d81570d5c 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -235,10 +235,7 @@ cupsdCheckJobs(void) curtime = time(NULL); - cupsdLogMessage(CUPSD_LOG_DEBUG2, - "cupsdCheckJobs: %d active jobs, sleeping=%d, reload=%d, " - "curtime=%ld", cupsArrayCount(ActiveJobs), Sleeping, - NeedReload, (long)curtime); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckJobs: %d active jobs, sleeping=%d, ac-power=%d, reload=%d, curtime=%ld", cupsArrayCount(ActiveJobs), Sleeping, ACPower, NeedReload, (long)curtime); for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs); job; @@ -332,7 +329,7 @@ cupsdCheckJobs(void) */ if (job->state_value == IPP_JOB_PENDING && !NeedReload && - !Sleeping && !DoingShutdown && !job->printer) + (!Sleeping || ACPower) && !DoingShutdown && !job->printer) { printer = cupsdFindDest(job->dest); pclass = NULL; diff --git a/scheduler/main.c b/scheduler/main.c index 48789a1cf9..259efd78e6 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -119,8 +119,7 @@ main(int argc, /* I - Number of command-line args */ int run_as_child = 0; /* Needed for background fork/exec */ #ifdef __APPLE__ - int use_sysman = !getuid(); - /* Use system management functions? */ + int use_sysman = 1; /* Use system management functions? */ #else time_t netif_time = 0; /* Time since last network update */ #endif /* __APPLE__ */ @@ -137,7 +136,7 @@ main(int argc, /* I - Number of command-line args */ if (getuid() != geteuid()) { - fputs("cupsd: Cannot run as a setuid program\n", stderr); + fputs("cupsd: Cannot run as a setuid program.\n", stderr); return (1); } #endif /* HAVE_GETEUID */ diff --git a/scheduler/sysman.c b/scheduler/sysman.c index 16d10eb87d..404ff9a57f 100644 --- a/scheduler/sysman.c +++ b/scheduler/sysman.c @@ -3,7 +3,7 @@ * * System management functions for the CUPS scheduler. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -19,31 +19,29 @@ */ #include "cupsd.h" -#ifdef HAVE_VPROC_TRANSACTION_BEGIN -# include -#endif /* HAVE_VPROC_TRANSACTION_BEGIN */ #ifdef __APPLE__ +# include # include #endif /* __APPLE__ */ /* * The system management functions cover disk and power management which - * are primarily used on portable computers. + * are primarily used for portable computers. * * Disk management involves delaying the write of certain configuration * and state files to minimize the number of times the disk has to spin - * up. + * up or flash to be written to. * * Power management support is currently only implemented on OS X, 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. - * - * Once put to sleep, we invalidate all remote printers since it is common - * to wake up in a new location/on a new wireless network. + * printing a job. And on OS X we can also "sleep print" - basically the + * system only wakes up long enough to service network requests and process + * print jobs. */ + /* * 'cupsdCleanDirty()' - Write dirty config and state files. */ @@ -132,9 +130,10 @@ cupsdSetBusyState(void) "Active clients and printing jobs", "Active clients, printing jobs, and dirty files" }; -#ifdef HAVE_VPROC_TRANSACTION_BEGIN +#ifdef __APPLE__ static vproc_transaction_t vtran = 0; /* Current busy transaction */ -#endif /* HAVE_VPROC_TRANSACTION_BEGIN */ + static IOPMAssertionID keep_awake = 0;/* Keep the system awake while printing */ +#endif /* __APPLE__ */ /* @@ -174,7 +173,7 @@ cupsdSetBusyState(void) { busy = newbusy; -#ifdef HAVE_VPROC_TRANSACTION_BEGIN +#ifdef __APPLE__ if (busy && !vtran) vtran = vproc_transaction_begin(NULL); else if (!busy && vtran) @@ -182,8 +181,25 @@ cupsdSetBusyState(void) vproc_transaction_end(NULL, vtran); vtran = 0; } -#endif /* HAVE_VPROC_TRANSACTION_BEGIN */ +#endif /* __APPLE__ */ + } + +#ifdef __APPLE__ + if (cupsArrayCount(PrintingJobs) > 0 && !keep_awake) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "Asserting NetworkClientActive."); + + IOPMAssertionCreateWithName(kIOPMAssertNetworkClientActive, + kIOPMAssertionLevelOn, + CFSTR("org.cups.cupsd"), &keep_awake); } + else if (cupsArrayCount(PrintingJobs) == 0 && keep_awake) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, "Releasing power assertion."); + IOPMAssertionRelease(keep_awake); + keep_awake = 0; + } +#endif /* __APPLE__ */ } @@ -198,8 +214,10 @@ cupsdSetBusyState(void) * Include MacOS-specific headers... */ +# include # include # include +# include # include # include # include @@ -265,6 +283,7 @@ static CFStringRef ComputerNameKey = NULL, /* Netowrk interface key */ static cupsd_sysevent_t LastSysEvent; /* Last system event (for delayed sleep) */ static int NameChanged = 0;/* Did we get a 'name changed' event during sleep? */ +static int PSToken = 0; /* Power source notifications */ /* @@ -308,6 +327,8 @@ cupsdStartSystemMonitor(void) int flags; /* fcntl flags on pipe */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartSystemMonitor()"); + if (cupsdOpenPipe(SysEventPipes)) { cupsdLogMessage(CUPSD_LOG_ERROR, "System event monitor pipe() failed - %s!", @@ -332,6 +353,14 @@ cupsdStartSystemMonitor(void) pthread_mutex_init(&SysEventThreadMutex, NULL); pthread_cond_init(&SysEventThreadCond, NULL); pthread_create(&SysEventThread, NULL, (void *(*)())sysEventThreadEntry, NULL); + + /* + * Monitor for power source changes via dispatch queue... + */ + + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartSystemMonitor: IOPSGetTimeRemainingEstimate=%f", IOPSGetTimeRemainingEstimate()); + ACPower = IOPSGetTimeRemainingEstimate() == kIOPSTimeRemainingUnlimited; + notify_register_dispatch(kIOPSNotifyPowerSource, &PSToken, dispatch_get_main_queue(), ^(int t) { ACPower = IOPSGetTimeRemainingEstimate() == kIOPSTimeRemainingUnlimited; }); } @@ -345,6 +374,8 @@ cupsdStopSystemMonitor(void) CFRunLoopRef rl; /* The event handler runloop */ + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStopSystemMonitor()"); + if (SysEventThread) { /* @@ -375,6 +406,12 @@ cupsdStopSystemMonitor(void) cupsdRemoveSelect(SysEventPipes[0]); cupsdClosePipe(SysEventPipes); } + + if (PSToken != 0) + { + notify_cancel(PSToken); + PSToken = 0; + } } diff --git a/scheduler/sysman.h b/scheduler/sysman.h index 810b185f0d..e3497ed0eb 100644 --- a/scheduler/sysman.h +++ b/scheduler/sysman.h @@ -1,16 +1,16 @@ /* * "$Id$" * - * System management definitions for the CUPS scheduler. + * System management definitions for the CUPS scheduler. * - * Copyright 2007-2011 by Apple Inc. - * Copyright 2006 by Easy Software Products. + * Copyright 2007-2014 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/". + * 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/". */ /* @@ -35,7 +35,9 @@ VAR int DirtyFiles VALUE(CUPSD_DIRTY_NONE), /* How often do we write dirty files? */ VAR time_t DirtyCleanTime VALUE(0); /* When to clean dirty files next */ -VAR int Sleeping VALUE(0); +VAR int ACPower VALUE(-1), + /* Is the system on AC power? */ + Sleeping VALUE(0); /* Non-zero if machine is entering or * * in a sleep state... */ VAR time_t SleepJobs VALUE(0); diff --git a/xcode/config.h b/xcode/config.h index 94a6f5d853..89e2b0b104 100644 --- a/xcode/config.h +++ b/xcode/config.h @@ -624,13 +624,6 @@ #endif /* HAVE_ARC4RANDOM */ -/* - * Do we have vproc_transaction_begin/end? - */ - -#define HAVE_VPROC_TRANSACTION_BEGIN 1 - - /* * Do we have libusb? */