[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/cups/FC-5 cups-str1736.patch,NONE,1.1 cups.spec,1.188,1.189



Author: twaugh

Update of /cvs/dist/rpms/cups/FC-5
In directory cvs.devel.redhat.com:/tmp/cvs-serv5794

Modified Files:
	cups.spec 
Added Files:
	cups-str1736.patch 
Log Message:
* Wed Jun  7 2006 Tim Waugh <twaugh redhat com>
- Prevent 'too many open files' error (STR #1736, bug #194368).


cups-str1736.patch:
 client.c |   27 +++++++++--------
 job.c    |   99 +++++++++++++++++++++------------------------------------------
 2 files changed, 48 insertions(+), 78 deletions(-)

--- NEW FILE cups-str1736.patch ---
--- cups-1.2.1/scheduler/client.c.str1736	2006-06-07 15:58:40.000000000 +0100
+++ cups-1.2.1/scheduler/client.c	2006-06-07 16:59:06.000000000 +0100
@@ -1882,24 +1882,27 @@
 
 
   if (con->filename)
+  {
     fd = open(con->filename, O_RDONLY);
-  else
-    fd = open("/dev/null", O_RDONLY);
 
-  if (fd < 0)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
-                    con->http.fd, con->filename ? con->filename : "/dev/null",
-	            strerror(errno));
-    return (0);
-  }
+    if (fd < 0)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "cupsdSendCommand: %d Unable to open \"%s\" for reading: %s",
+                      con->http.fd, con->filename ? con->filename : "/dev/null",
+	              strerror(errno));
+      return (0);
+    }
 
-  fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+    fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+  }
+  else
+    fd = -1;
 
   con->pipe_pid = pipe_command(con, fd, &(con->file), command, options, root);
 
-  close(fd);
+  if (fd >= 0)
+    close(fd);
 
   cupsdLogMessage(CUPSD_LOG_INFO, "Started \"%s\" (pid=%d)", command,
                   con->pipe_pid);
--- cups-1.2.1/scheduler/job.c.str1736	2006-06-07 15:58:40.000000000 +0100
+++ cups-1.2.1/scheduler/job.c	2006-06-07 16:59:06.000000000 +0100
@@ -3090,28 +3090,6 @@
   job->status = 0;
   memset(job->filters, 0, sizeof(job->filters));
 
-  filterfds[1][0] = open("/dev/null", O_RDONLY);
-
-  if (filterfds[1][0] < 0)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
-                    strerror(errno));
-    snprintf(printer->state_message, sizeof(printer->state_message),
-             "Unable to open \"/dev/null\" - %s.", strerror(errno));
-
-    cupsdAddPrinterHistory(printer);
-
-    cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
-                  "Job canceled because the server could not open /dev/null.");
-
-    goto abort_job;
-  }
-
-  fcntl(filterfds[1][0], F_SETFD, fcntl(filterfds[1][0], F_GETFD) | FD_CLOEXEC);
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job: filterfds[%d] = [ %d %d ]",
-                  1, filterfds[1][0], filterfds[1][1]);
-
   for (i = 0, slot = 0, filter = (mime_filter_t *)cupsArrayFirst(filters);
        filter;
        i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
@@ -3189,36 +3167,43 @@
 	else
 	{
 	  job->print_pipes[0] = -1;
-	  if (!strncmp(printer->device_uri, "file:/dev/", 10) &&
-	      strcmp(printer->device_uri, "file:/dev/null"))
-	    job->print_pipes[1] = open(printer->device_uri + 5,
-	                               O_WRONLY | O_EXCL);
-	  else if (!strncmp(printer->device_uri, "file:///dev/", 12) &&
-	           strcmp(printer->device_uri, "file:///dev/null"))
-	    job->print_pipes[1] = open(printer->device_uri + 7,
-	                               O_WRONLY | O_EXCL);
+	  if (!strcmp(printer->device_uri, "file:/dev/null") ||
+	      !strcmp(printer->device_uri, "file:///dev/null"))
+	    job->print_pipes[1] = -1;
 	  else
-	    job->print_pipes[1] = open(printer->device_uri + 5,
-	                               O_WRONLY | O_CREAT | O_TRUNC, 0600);
-
-	  if (job->print_pipes[1] < 0)
 	  {
-            cupsdLogMessage(CUPSD_LOG_ERROR,
-	                    "Unable to open output file \"%s\" - %s.",
-	                    printer->device_uri, strerror(errno));
-            snprintf(printer->state_message, sizeof(printer->state_message),
-		     "Unable to open output file \"%s\" - %s.",
-	             printer->device_uri, strerror(errno));
+	    if (!strncmp(printer->device_uri, "file:/dev/", 10))
+	      job->print_pipes[1] = open(printer->device_uri + 5,
+	                        	 O_WRONLY | O_EXCL);
+	    else if (!strncmp(printer->device_uri, "file:///dev/", 12))
+	      job->print_pipes[1] = open(printer->device_uri + 7,
+	                        	 O_WRONLY | O_EXCL);
+	    else if (!strncmp(printer->device_uri, "file:///", 8))
+	      job->print_pipes[1] = open(printer->device_uri + 7,
+	                        	 O_WRONLY | O_CREAT | O_TRUNC, 0600);
+	    else
+	      job->print_pipes[1] = open(printer->device_uri + 5,
+	                        	 O_WRONLY | O_CREAT | O_TRUNC, 0600);
 
-	    cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
-                	  "Job canceled because the server could not open the "
-			  "output file.");
+	    if (job->print_pipes[1] < 0)
+	    {
+              cupsdLogMessage(CUPSD_LOG_ERROR,
+	                      "Unable to open output file \"%s\" - %s.",
+	                      printer->device_uri, strerror(errno));
+              snprintf(printer->state_message, sizeof(printer->state_message),
+		       "Unable to open output file \"%s\" - %s.",
+	               printer->device_uri, strerror(errno));
+
+	      cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
+                	    "Job canceled because the server could not open the "
+			    "output file.");
 
-            goto abort_job;
-	  }
+              goto abort_job;
+	    }
 
-	  fcntl(job->print_pipes[1], F_SETFD,
-        	fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
+	    fcntl(job->print_pipes[1], F_SETFD,
+        	  fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
+          }
 	}
 
 	cupsdLogMessage(CUPSD_LOG_DEBUG2,
@@ -3320,25 +3305,7 @@
       argv[0] = sani_uri;
 
       filterfds[slot][0] = -1;
-      filterfds[slot][1] = open("/dev/null", O_WRONLY);
-
-      if (filterfds[slot][1] < 0)
-      {
-	cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to open \"/dev/null\" - %s.",
-	                strerror(errno));
-	snprintf(printer->state_message, sizeof(printer->state_message),
-        	 "Unable to open \"/dev/null\" - %s.", strerror(errno));
-
-	cupsdAddPrinterHistory(printer);
-
-	cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
-                      "Job canceled because the server could not open a file.");
-
-        goto abort_job;
-      }
-
-      fcntl(filterfds[slot][1], F_SETFD,
-            fcntl(filterfds[slot][1], F_GETFD) | FD_CLOEXEC);
+      filterfds[slot][1] = -1;
 
       cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job: backend=\"%s\"",
                       command);


Index: cups.spec
===================================================================
RCS file: /cvs/dist/rpms/cups/FC-5/cups.spec,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -r1.188 -r1.189
--- cups.spec	7 Jun 2006 14:52:22 -0000	1.188
+++ cups.spec	7 Jun 2006 16:01:10 -0000	1.189
@@ -41,6 +41,7 @@
 Patch18: cups-language.patch
 Patch19: cups-str1758.patch
 Patch20: cups-direct-usb.patch
+Patch21: cups-str1736.patch
 Patch22: cups-dest-cache-v2.patch
 Patch24: cups-maxlogsize.patch
 Patch28: cups-no-propagate-ipp-port.patch
@@ -143,6 +144,7 @@
 %patch18 -p1 -b .language
 %patch19 -p1 -b .str1758
 %patch20 -p1 -b .direct-usb
+%patch21 -p1 -b .str1736
 %patch22 -p1 -b .dest-cache-v2
 %patch24 -p1 -b .maxlogsize
 %patch28 -p1 -b .no-propagate-ipp-port
@@ -411,6 +413,9 @@
 %{cups_serverbin}/daemon/cups-lpd
 
 %changelog
+* Wed Jun  7 2006 Tim Waugh <twaugh redhat com>
+- Prevent 'too many open files' error (STR #1736, bug #194368).
+
 * Wed Jun  7 2006 Tim Waugh <twaugh redhat com> 1:1.2.1-1.6
 - Fix 'Allow from @IF(...)' (STR #1758, bug #187703).
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]