--- ab.c.orig	Tue Mar 12 16:52:49 2002
+++ ab.c	Tue Mar 12 17:29:10 2002
@@ -128,6 +128,10 @@
 /* affects include files on Solaris */
 #define BSD_COMP
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
 #include "apr.h"
 #include "apr_strings.h"
 #include "apr_network_io.h"
@@ -241,6 +245,10 @@
     apr_interval_time_t time;       /* time in ms for connection */
 };
 
+#ifdef SUNOS4
+#struct rlimit rlp;
+#endif
+
 #define ap_min(a,b) ((a)<(b))?(a):(b)
 #define ap_max(a,b) ((a)>(b))?(a):(b)
 
@@ -1137,6 +1145,32 @@
 	       (heartbeatres ? "\n" : "..."));
 	fflush(stdout);
     }
+
+#ifdef SUNOS4
+    /*
+     *  set the file descriptor limit to the max hard limit
+     *
+     *  the default limit may be displayed by:
+     *
+     *      ulimit -n
+     *
+     *  the following code is the equivalent of:
+     *
+     *      ulimit -n unlimited
+     *
+     *  which sets the number of available file handles to the hard
+     *  limit as defined at system configuration (unless this command
+     *  is executed as 'root' in which case it will set the number of
+     *  available file handles to 'unlimited').
+     */
+
+    getrlimit( RLIMIT_NOFILE, &rlp );
+    rlp.rlim_cur = rlp.rlim_max;
+    printf("\r\nINFO: Current file limit = %d, re-setting to %d \r\n", rlp.rlim_cur, rlp.rlim_max);
+    if (setrlimit( RLIMIT_NOFILE, &rlp) == -1) {
+        printf("INFO: Could not set file limit to %d \r\n", rlp.rlim_max);
+    }
+#endif
 
     now = apr_time_now();
 
