SOURCES: cups-str1736.patch (NEW) - fixed bug: 'Unable to open "/d...

charles charles at pld-linux.org
Mon Jun 5 15:20:54 CEST 2006


Author: charles                      Date: Mon Jun  5 13:20:54 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- fixed bug: 'Unable to open "/dev/null" - Too many open files' (fixed in CUPS svn)

---- Files affected:
SOURCES:
   cups-str1736.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/cups-str1736.patch
diff -u /dev/null SOURCES/cups-str1736.patch:1.1
--- /dev/null	Mon Jun  5 15:20:54 2006
+++ SOURCES/cups-str1736.patch	Mon Jun  5 15:20:49 2006
@@ -0,0 +1,169 @@
+--- cups-1.2.1/scheduler/client.c.orig	2006-05-22 17:34:01.000000000 +0200
++++ cups-1.2.1/scheduler/client.c	2006-06-05 14:54:53.436660500 +0200
+@@ -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.orig	2006-05-18 23:00:56.000000000 +0200
++++ cups-1.2.1/scheduler/job.c	2006-06-05 14:44:04.660114500 +0200
+@@ -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))
+@@ -3165,36 +3143,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));
+ 
+-            goto abort_job;
+-	  }
++	      cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job,
++                	    "Job canceled because the server could not open the "
++			    "output file.");
+ 
+-	  fcntl(job->print_pipes[1], F_SETFD,
+-        	fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
++              goto abort_job;
++	    }
++
++	    fcntl(job->print_pipes[1], F_SETFD,
++        	  fcntl(job->print_pipes[1], F_GETFD) | FD_CLOEXEC);
++          }
+ 	}
+ 
+ 	cupsdLogMessage(CUPSD_LOG_DEBUG2,
+@@ -3274,25 +3259,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);
================================================================


More information about the pld-cvs-commit mailing list