[httperf] The glibc FD_SETSIZE problem and a solution

Jesse Byler lists.httperf at web19.eml.cc
Tue Nov 29 07:58:51 PST 2005


Looks like the actual patches didn't make it through the mailing list 
filter.  Here's another attempt, with the MIME types set to 
text/plain instead of text/x-diff.
-------------- next part --------------
diff -Naur httperf-0.8/core.c httperf-0.8-jtjm/core.c
--- httperf-0.8/core.c	2000-10-31 23:57:50.000000000 +0000
+++ httperf-0.8-jtjm/core.c	2005-11-24 19:38:25.000000000 +0000
@@ -51,7 +51,7 @@
 #include <event.h>
 #include <http.h>
 #include <conn.h>
-
+#include "fd_set.h"
 #define HASH_TABLE_SIZE	1024	/* can't have more than this many servers */
 #define MIN_IP_PORT	IPPORT_RESERVED
 #define MAX_IP_PORT	65535
@@ -60,7 +60,7 @@
 static int running = 1;
 static int iteration;
 static u_long max_burst_len;
-static fd_set rdfds, wrfds;
+static jtjm_fd_set rdfds, wrfds;
 static int min_sd = 0x7fffffff, max_sd = 0, alloced_sd_to_conn = 0;
 static struct timeval select_timeout;
 static struct sockaddr_in myaddr;
@@ -317,7 +317,7 @@
 }
 
 static void
-set_active (Conn *s, fd_set *fdset)
+set_active (Conn *s, jtjm_fd_set *fdset)
 {
   int sd = s->sd;
   Any_Type arg;
@@ -672,11 +672,11 @@
       exit (1);
     }
 
-  if (rlimit.rlim_max > FD_SETSIZE)
+  if (rlimit.rlim_max > LOCAL_FD_SETSIZE)
     {
-      fprintf (stderr, "%s: warning: open file limit > FD_SETSIZE; "
-	       "limiting max. # of open files to FD_SETSIZE\n", prog_name);
-      rlimit.rlim_max = FD_SETSIZE;
+      fprintf (stderr, "%s: warning: open file limit > LOCAL_FD_SETSIZE; "
+	       "limiting max. # of open files to LOCAL_FD_SETSIZE\n", prog_name);
+      rlimit.rlim_max = LOCAL_FD_SETSIZE;
     }
 
   rlimit.rlim_cur = rlimit.rlim_max;
@@ -1103,7 +1103,7 @@
 core_loop (void)
 {
   int is_readable, is_writable, n, sd, bit, min_i, max_i, i = 0;
-  fd_set readable, writable;
+  jtjm_fd_set readable, writable;
   fd_mask mask;
   Any_Type arg;
   Conn *conn;
diff -Naur httperf-0.8/fd_set.h httperf-0.8-jtjm/fd_set.h
--- httperf-0.8/fd_set.h	1970-01-01 01:00:00.000000000 +0100
+++ httperf-0.8-jtjm/fd_set.h	2005-11-24 19:33:50.000000000 +0000
@@ -0,0 +1,8 @@
+#define LOCAL_FD_SETSIZE 102400
+
+typedef long int __jtjm_fd_mask;
+typedef struct
+  {
+      __jtjm_fd_mask fds_bits[LOCAL_FD_SETSIZE / (8 * sizeof (__jtjm_fd_mask))];
+
+  } jtjm_fd_set;
diff -Naur httperf-0.8/idleconn.c httperf-0.8-jtjm/idleconn.c
--- httperf-0.8/idleconn.c	2000-10-12 00:35:38.000000000 +0100
+++ httperf-0.8-jtjm/idleconn.c	2005-11-24 19:35:29.000000000 +0000
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/resource.h>
 #include <sys/socket.h>
+#include "fd_set.h"
 
 const char *prog_name;
 unsigned long num_conn, num_closed;
@@ -63,7 +64,7 @@
 {
   int desired, current = 0, port, sd, max_sd = 0, n, i;
   struct sockaddr_in sin, server_addr;
-  fd_set readable, rdfds;
+  jtjm_fd_set readable, rdfds;
   struct rlimit rlimit;
   struct hostent *he;
   char *server;
@@ -96,11 +97,11 @@
       exit (1);
     }
 
-  if (rlimit.rlim_max > FD_SETSIZE)
+  if (rlimit.rlim_max > LOCAL_FD_SETSIZE)
     {
-      fprintf (stderr, "%s: warning: open file limit > FD_SETSIZE; "
-	       "limiting max. # of open files to FD_SETSIZE\n", prog_name);
-      rlimit.rlim_max = FD_SETSIZE;
+      fprintf (stderr, "%s: warning: open file limit > LOCAL_FD_SETSIZE; "
+	       "limiting max. # of open files to LOCAL_FD_SETSIZE\n", prog_name);
+      rlimit.rlim_max = LOCAL_FD_SETSIZE;
     }
 
   rlimit.rlim_cur = rlimit.rlim_max;
-------------- next part --------------
diff -cr httperf-0.8-jtjm/Makefile.in httperf-0.8-jj/Makefile.in
*** httperf-0.8-jtjm/Makefile.in	Thu Oct 19 03:38:59 2000
--- httperf-0.8-jj/Makefile.in	Mon Nov 28 12:46:27 2005
***************
*** 6,11 ****
--- 6,12 ----
  top_builddir = .
  
  prefix = @prefix@
+ exec_prefix = @exec_prefix@
  bindir = @bindir@
  mandir = @mandir@
  


More information about the httperf mailing list