]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Delete temporary printers periodically and on shutdown (Issue #5003)
authorMichael Sweet <michael.r.sweet@gmail.com>
Thu, 25 May 2017 18:02:12 +0000 (14:02 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Thu, 25 May 2017 18:02:12 +0000 (14:02 -0400)
CHANGES.md
scheduler/main.c
scheduler/printers.c
scheduler/printers.h

index 3e0d9d8a41a600fbc9ff097b1b91979c3485b79a..9e7f7ace2044012876e99960f5809eb3f28640e8 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES - 2.2.4 - 2017-05-17
+CHANGES - 2.2.4 - 2017-05-25
 ============================
 
 CHANGES IN CUPS V2.2.4
@@ -16,6 +16,8 @@ CHANGES IN CUPS V2.2.4
 - IPP Everywhere improvements (Issue #4998)
 - Fixed the "cancel all jobs" function in the web interface for several
   languages (Issue #4999)
+- The scheduler was not deleting temporary queues, leaving behind PPD files
+  (Issue #5003)
 
 
 CHANGES IN CUPS V2.2.3
index bdb27a6db622cfa0f2fa5a1d3a0082aa703f337d..bdfddf983a6200e161b9b8b0b395d6b55f354d60 100644 (file)
@@ -1022,7 +1022,10 @@ main(int  argc,                          /* I - Number of command-line args */
     */
 
     if (JobHistoryUpdate && current_time >= JobHistoryUpdate)
+    {
       cupsdCleanJobs();
+      cupsdDeleteTemporaryPrinters(0);
+    }
 
    /*
     * Log statistics at most once a minute when in debug mode...
@@ -1152,6 +1155,12 @@ main(int  argc,                          /* I - Number of command-line args */
 
   cupsdFreeAllJobs();
 
+ /*
+  * Delete all temporary printers...
+  */
+
+  cupsdDeleteTemporaryPrinters(1);
+
 #ifdef __APPLE__
  /*
   * Stop monitoring system event monitoring...
@@ -1631,13 +1640,13 @@ select_timeout(int fds)                 /* I - Number of descriptors returned */
 
 #ifdef __APPLE__
  /*
-  * When going to sleep, wake up to cancel jobs that don't complete in time.
+  * When going to sleep, wake up to abort jobs that don't complete in time.
   */
 
   if (SleepJobs > 0 && SleepJobs < timeout)
   {
     timeout = SleepJobs;
-    why     = "cancel jobs before sleeping";
+    why     = "abort jobs before sleeping";
   }
 #endif /* __APPLE__ */
 
index e17d331eee67c1e1e66dbad7c32d23b41a71aff4..1c81c5504d0dfd08e3adfaaee3baaa5bf1031526 100644 (file)
@@ -756,11 +756,6 @@ cupsdDeletePrinter(
     * Remove any old PPD or script files...
     */
 
-    snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, p->name);
-    unlink(filename);
-    snprintf(filename, sizeof(filename), "%s/interfaces/%s.O", ServerRoot, p->name);
-    unlink(filename);
-
     snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, p->name);
     unlink(filename);
     snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd.O", ServerRoot, p->name);
@@ -839,6 +834,32 @@ cupsdDeletePrinter(
 }
 
 
+/*
+ * 'cupsdDeleteTemporaryPrinters()' - Delete unneeded temporary printers.
+ */
+
+void
+cupsdDeleteTemporaryPrinters(int force) /* I - Force deletion instead of auto? */
+{
+  cupsd_printer_t *p;                   /* Current printer */
+  time_t          unused_time;          /* Last time for printer state change */
+
+
+ /*
+  * Allow temporary printers to stick around for 60 seconds after the last job
+  * completes.
+  */
+
+  unused_time = time(NULL) - 60;
+
+  for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers))
+  {
+    if (p->temporary && (force || p->state_time < unused_time))
+      cupsdDeletePrinter(p, 0);
+  }
+}
+
+
 /*
  * 'cupsdFindDest()' - Find a destination in the list.
  */
index c63b4711f06cfe03817d52a61997bd3300ce8cb4..e1d991016a7849deb1fbb2b77d201b09b532eaa7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Printer definitions for the CUPS scheduler.
  *
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -156,6 +156,7 @@ extern cupsd_printer_t      *cupsdAddPrinter(const char *name);
 extern void            cupsdCreateCommonData(void);
 extern void            cupsdDeleteAllPrinters(void);
 extern int             cupsdDeletePrinter(cupsd_printer_t *p, int update);
+extern void             cupsdDeleteTemporaryPrinters(int force);
 extern cupsd_printer_t *cupsdFindDest(const char *name);
 extern cupsd_printer_t *cupsdFindPrinter(const char *name);
 extern cupsd_quota_t   *cupsdFindQuota(cupsd_printer_t *p,