You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/11/09 10:32:43 UTC

[PATCH] PR#1181: diagnose low descriptor situations

When an F_DUPFD fails to dup above the low slack line the server is in
danger of having too few descriptors to function properly.  We can
diagnose this at config time... and this is likely to be far more useful
to users than having them guess why things are randomly failing (like DNS
or CGI spawning).

Dean

Index: main/util.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/util.c,v
retrieving revision 1.75
diff -u -r1.75 util.c
--- util.c	1997/10/27 16:30:30	1.75
+++ util.c	1997/11/09 09:30:29
@@ -66,9 +66,7 @@
 
 #include "httpd.h"
 #include "http_conf_globals.h"	/* for user_id & group_id */
-#if defined(DEBUG)||defined(DEBUG_CFG_LINES)
 #include "http_log.h"
-#endif
 #include <stdio.h>
 
 const char month_snames[12][4] =
@@ -1620,6 +1618,7 @@
 #if !defined(F_DUPFD)
     return fd;
 #else
+    static int low_warned;
     int new_fd;
 
 #ifdef HIGH_SLACK_LINE
@@ -1637,6 +1636,20 @@
     }
     new_fd = fcntl(fd, F_DUPFD, LOW_SLACK_LINE);
     if (new_fd == -1) {
+	if (!low_warned) {
+	    /* Give them a warning here, because we really can't predict
+	     * how libraries and such are going to fail.  If we can't
+	     * do this F_DUPFD there's a good chance that apache has too
+	     * few descriptors available to it.  Note we don't warn on
+	     * the high line, because if it fails we'll eventually try
+	     * the low line...
+	     */
+	    aplog_error(APLOG_MARK, APLOG_ERR, NULL,
+		"unable to open a file descriptor above %u, "
+		"you may need to increase the number of descriptors",
+		LOW_SLACK_LINE);
+	    low_warned = 1;
+	}
 	return fd;
     }
     close(fd);