Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When cupsd is loaded, set queue to stopped if required backend does not exist #1265

Closed
michaelrsweet opened this issue Sep 8, 2005 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2-feature
CUPS.org User: jfehlig

If a backend required by a queue does not exist, set the queue state to stopped when cupsd is loaded. No use having the queue in ready state when there will be no possibility to print jobs due to non-existent backend.

Attached is a patch to scheduler/printers.c created from trunk. Added a local function named check_printer_state_at_load() which at this time only verifies that backend specified by scheme component of device uri actually exists in the proper location. The check is ignored if backend type is "file".

check_printer_state_at_load() is called by LoadAllPrinters() after the entire printer record is read from printers.conf. Additional state checks may be added to check_printer_state_at_load() in the future.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

I just added an in-line check after is seen in the printers.conf file...

@michaelrsweet
Copy link
Collaborator Author

"printers.c.patch":

Index: printers.c

--- printers.c (revision 4627)
+++ printers.c (working copy)
@@ -48,6 +48,9 @@

  •                        desktop tools.
    
  • write_irix_state() - Update the status files used by IRIX printing

  •                        desktop tools.
    
    • * check_printer_state_at_load() - Check the printer state at load time.
    • * For now just verify that a backend exists
    • * to support the specified printer.
      */

    /*
    @@ -66,6 +69,8 @@
    static void write_irix_state(printer_t p);
    #endif /
    __sgi */

+static void check_printer_state_at_load(printer_t *p);
+

/*

  • 'AddPrinter()' - Add a printer to the system.
    @@ -876,6 +881,8 @@
    {
    SetPrinterAttrs(p);
    AddPrinterHistory(p);

    •    check_printer_state_at_load(p);
      
      p = NULL;
      }
      else
      @@ -2684,5 +2691,35 @@

    /*

    • * 'check_printer_state_at_load()' - Check the printer state at load time.
    • * For now just verify that a backend exists to support the specified
    • * printer.
    • /
      +
      +static void
      +check_printer_state_at_load(printer_t *p) /
      I - Printer to check */
      +{
    • char scheme[255]; /* Scheme protion of device URI */
    • char command[1024]; /* Full path to backend command */
    • struct stat stat_buf; /* stat buffer for receiving file status */
    • if (!p || !p->device_uri)
    •  return;
      
    • if (strncmp(p->device_uri, "file:", 5) != 0)
    • {
    •  sscanf(p->device_uri, "%254[^:]", scheme);
      
    •  snprintf(command, sizeof(command), "%s/backend/%s", ServerBin, scheme);
      
    •  if (stat(command, &stat_buf) && errno == ENOENT)
      
    •  {
      
    •     LogMessage(L_ERROR, "Backend \"%s\" does not exist.", command);
      
    •     StopPrinter(p, 1);
      
    •  }
      
    • }
      +}

    +/*

  • End of "$Id$".
    */

@michaelrsweet michaelrsweet added the enhancement New feature or request label Mar 17, 2016
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant