From: Michael R Sweet Date: Mon, 2 May 2022 20:11:07 +0000 (-0400) Subject: Report when scheduler is not running (Issue #352) X-Git-Tag: v2.4.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84e77073fa1881f3c38e4b5bce53a48b7866656b;p=thirdparty%2Fcups.git Report when scheduler is not running (Issue #352) --- diff --git a/CHANGES.md b/CHANGES.md index 2516e23271..aac4aa81d6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,8 @@ Changes in CUPS v2.4.2 (TBA) - Fixed copyright in CUPS Web UI trailer template (Issue #346) - mDNS hostname in device uri is not resolved when installaling a permanent IPP Everywhere queue (Issues #340, #343) +- The `lpstat` command now reports when the scheduler is not running + (Issue #352) - Updated the man pages concerning the `-h` option (Issue #357) - Re-added LibreSSL/OpenSSL support (Issue #362) - Updated the Solaris smf service file (Issue #368) diff --git a/systemv/lpstat.c b/systemv/lpstat.c index 7cb1eeb53a..357999d539 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -33,7 +33,7 @@ static int show_jobs(const char *dests, const char *users, int long_status, int ranking, const char *which); static int show_printers(const char *printers, int num_dests, cups_dest_t *dests, int long_status); -static void show_scheduler(void); +static int show_scheduler(void); static void usage(void) _CUPS_NORETURN; @@ -378,7 +378,8 @@ main(int argc, /* I - Number of command-line arguments */ case 'r' : /* Show scheduler status */ op = 'r'; - show_scheduler(); + if (!show_scheduler()) + return (0); break; case 's' : /* Show summary */ @@ -420,7 +421,9 @@ main(int argc, /* I - Number of command-line arguments */ } } - show_scheduler(); + if (!show_scheduler()) + return (0); + show_default(cupsGetDest(NULL, NULL, num_dests, dests)); status |= show_classes(NULL); status |= show_devices(NULL, num_dests, dests); @@ -722,8 +725,13 @@ show_accepting(const char *printers, /* I - Destinations */ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/"); - if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || - cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) + if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE) + { + _cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat"); + ippDelete(response); + return (1); + } + else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) { _cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), @@ -902,6 +910,12 @@ show_classes(const char *dests) /* I - Destinations */ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/"); + if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE) + { + _cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat"); + ippDelete(response); + return (1); + } if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) { @@ -1160,6 +1174,12 @@ show_devices(const char *printers, /* I - Destinations */ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/"); + if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE) + { + _cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat"); + ippDelete(response); + return (1); + } if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) { @@ -1352,6 +1372,12 @@ show_jobs(const char *dests, /* I - Destinations */ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/"); + if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE) + { + _cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat"); + ippDelete(response); + return (1); + } if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) { @@ -1589,6 +1615,12 @@ show_printers(const char *printers, /* I - Destinations */ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/"); + if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE) + { + _cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat"); + ippDelete(response); + return (1); + } if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED) { @@ -2019,7 +2051,7 @@ show_printers(const char *printers, /* I - Destinations */ * 'show_scheduler()' - Show scheduler status. */ -static void +static int /* 1 on success, 0 on failure */ show_scheduler(void) { http_t *http; /* Connection to server */ @@ -2030,9 +2062,13 @@ show_scheduler(void) { _cupsLangPuts(stdout, _("scheduler is running")); httpClose(http); + return (1); } else + { _cupsLangPuts(stdout, _("scheduler is not running")); + return (0); + } }