[netperf-dev] netperf2 commit notice r75 - in trunk: . src

raj at netperf.org raj at netperf.org
Wed May 24 10:32:08 PDT 2006


Author: raj
Date: 2006-05-24 10:32:06 -0700 (Wed, 24 May 2006)
New Revision: 75

Modified:
   trunk/AUTHORS
   trunk/Release_Notes
   trunk/config.h.in
   trunk/configure
   trunk/configure.ac
   trunk/src/netserver.c
   trunk/src/nettest_bsd.c
Log:
Include patches from Hans Blom for handling stdin/stdout/stderr in netserver
and patches from Andrew Gallatin to beter handle sendfile in Solaris.


Modified: trunk/AUTHORS
===================================================================
--- trunk/AUTHORS	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/AUTHORS	2006-05-24 17:32:06 UTC (rev 75)
@@ -176,3 +176,6 @@
 Bret McKee <bret at hp.com>
 Fixes to get netcpu_looper compiling and working after the "netcpu"
 split
+
+Hans Blom
+Improvements to closing/redirecting stdin/stdout/stderr in netserver

Modified: trunk/Release_Notes
===================================================================
--- trunk/Release_Notes	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/Release_Notes	2006-05-24 17:32:06 UTC (rev 75)
@@ -1,3 +1,13 @@
+These are the Release Notes leading-up to Revision 2.4.3 of netperf:
+
+Things changed in this release:
+
+*) More complete closing/redirecting of stdin/stdout/stderr/where in
+   netserver to make it easier to launch netserver at the far-end of a
+   remote shell.  Courtesy of Hans Blom.
+
+*) Sendfile changes for Solaris courtesy of Andrew Gallatin.
+
 These are the Release Notes for Revision 2.4.2 of netperf:
 
 Things changed in this release:

Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/config.h.in	2006-05-24 17:32:06 UTC (rev 75)
@@ -81,6 +81,9 @@
 /* Define to 1 if you have the `sctp' library (-lsctp). */
 #undef HAVE_LIBSCTP
 
+/* Define to 1 if you have the `sendfile' library (-lsendfile). */
+#undef HAVE_LIBSENDFILE
+
 /* Define to 1 if you have the `socket' library (-lsocket). */
 #undef HAVE_LIBSOCKET
 
@@ -313,6 +316,12 @@
 /* Define to one to include XTI tests. */
 #undef WANT_XTI
 
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 

Modified: trunk/configure
===================================================================
--- trunk/configure	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/configure	2006-05-24 17:32:06 UTC (rev 75)
@@ -855,6 +855,7 @@
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-dependency-tracking Speeds up one-time builds
   --enable-dependency-tracking  Do not reject slow dependency extractors
+  --disable-largefile     omit support for large files
   --enable-histogram      include individual op timing, may affect result
   --enable-dirty          write to buffers each time, may affect result
   --enable-demo           emit interim results during the run. May affect
@@ -3954,8 +3955,434 @@
 fi
 ac_cv_lib_nsl=ac_cv_lib_nsl_main
 
+
+echo "$as_me:$LINENO: checking for main in -lsendfile" >&5
+echo $ECHO_N "checking for main in -lsendfile... $ECHO_C" >&6
+if test "${ac_cv_lib_sendfile_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsendfile  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_sendfile_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_sendfile_main=no
 fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_sendfile_main" >&5
+echo "${ECHO_T}$ac_cv_lib_sendfile_main" >&6
+if test $ac_cv_lib_sendfile_main = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSENDFILE 1
+_ACEOF
 
+  LIBS="-lsendfile $LIBS"
+
+fi
+ac_cv_lib_sendfile=ac_cv_lib_sendfile_main
+
+    # Check whether --enable-largefile or --disable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+  enableval="$enable_largefile"
+
+fi;
+if test "$enable_largefile" != no; then
+
+  echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
+echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_largefile_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_sys_largefile_CC=no
+     if test "$GCC" != yes; then
+       ac_save_CC=$CC
+       while :; do
+     	 # IRIX 6.2 and later do not support large files by default,
+     	 # so use the C compiler's -n32 option if that helps.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+     	 rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+     	 CC="$CC -n32"
+     	 rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_largefile_CC=' -n32'; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+	 break
+       done
+       CC=$ac_save_CC
+       rm -f conftest.$ac_ext
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
+echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6
+  if test "$ac_cv_sys_largefile_CC" != no; then
+    CC=$CC$ac_cv_sys_largefile_CC
+  fi
+
+  echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_file_offset_bits+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  while :; do
+  ac_cv_sys_file_offset_bits=no
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_file_offset_bits=64; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  break
+done
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
+echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6
+if test "$ac_cv_sys_file_offset_bits" != no; then
+
+cat >>confdefs.h <<_ACEOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+_ACEOF
+
+fi
+rm -f conftest*
+  echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
+echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_large_files+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  while :; do
+  ac_cv_sys_large_files=no
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#define _LARGE_FILES 1
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_large_files=1; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  break
+done
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
+echo "${ECHO_T}$ac_cv_sys_large_files" >&6
+if test "$ac_cv_sys_large_files" != no; then
+
+cat >>confdefs.h <<_ACEOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+_ACEOF
+
+fi
+rm -f conftest*
+fi
+
+fi
+
 # this one is for Tru64 and bind_to_cpu_id
 
 echo "$as_me:$LINENO: checking for main in -lmach" >&5

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/configure.ac	2006-05-24 17:32:06 UTC (rev 75)
@@ -33,6 +33,8 @@
 AC_HAVE_LIBRARY(socket)
 if test "$ac_cv_lib_socket_main" = yes ; then
     AC_HAVE_LIBRARY(nsl)
+    AC_HAVE_LIBRARY(sendfile)
+    AC_SYS_LARGEFILE
 fi
 
 # this one is for Tru64 and bind_to_cpu_id

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/src/netserver.c	2006-05-24 17:32:06 UTC (rev 75)
@@ -190,7 +190,30 @@
       send_response();
       /* +SAF why??? */
       if (!debug) 
+      {
 	fclose(where);
+#if !defined(WIN32) && !defined(MPE) && !defined(__VMS)
+	/* For Unix: reopen the debug write file descriptor to "/dev/null" */
+	/* and redirect stdout to it.					   */
+	fflush (stdout);
+	where = fopen ("/dev/null", "w");
+	if (where == NULL)
+	{
+	  perror ("netserver: reopening debug fp for writing: /dev/null");
+	  exit   (1);
+	}
+	if (close (STDOUT_FILENO) == -1)
+	{
+	  perror ("netserver: closing stdout file descriptor");
+	  exit   (1);
+	}
+	if (dup (fileno (where))  == -1)
+	{
+	  perror ("netserver: duplicate /dev/null write file descr. to stdout");
+	  exit   (1);
+	}
+#endif /* !WIN32 !MPE !__VMS */
+      }
       break;
       
     case CPU_CALIBRATE:
@@ -377,6 +400,11 @@
   int error;
   int not_listening;
 
+#if !defined(WIN32) && !defined(MPE) && !defined(__VMS)
+  FILE *rd_null_fp;    /* Used to redirect from "/dev/null". */
+  FILE *wr_null_fp;    /* Used to redirect to   "/dev/null". */
+#endif /* !WIN32 !MPE !__VMS */
+
   if (debug) {
     fprintf(stderr,
             "set_up_server called with host '%s' port '%s' remfam %d\n",
@@ -491,6 +519,10 @@
     */
 
 #if !defined(WIN32) && !defined(MPE) && !defined(__VMS)
+  /* Flush the standard I/O file descriptors before forking. */
+  fflush (stdin);
+  fflush (stdout);
+  fflush (stderr);
   switch (fork())
     {
     case -1:  	
@@ -498,9 +530,53 @@
       exit(1);
       
     case 0:	
-      /* stdin/stderr should use fclose */
-      fclose(stdin);
-      fclose(stderr);
+      /* Redirect stdin from "/dev/null". */
+      rd_null_fp = fopen ("/dev/null", "r");
+      if (rd_null_fp == NULL)
+      {
+	perror ("netserver: opening for reading: /dev/null");
+	exit   (1);
+      }
+      if (close (STDIN_FILENO) == -1)
+      {
+	perror ("netserver: closing stdin file descriptor");
+	exit   (1);
+      }
+      if (dup (fileno (rd_null_fp)) == -1)
+      {
+	perror ("netserver: duplicate /dev/null read file descr. to stdin");
+	exit   (1);
+      }
+
+      /* Redirect stdout to the debug write file descriptor. */
+      if (close (STDOUT_FILENO) == -1)
+      {
+	perror ("netserver: closing stdout file descriptor");
+	exit   (1);
+      }
+      if (dup (fileno (where))  == -1)
+      {
+	perror ("netserver: duplicate the debug write file descr. to stdout");
+	exit   (1);
+      }
+
+      /* Redirect stderr to "/dev/null". */
+      wr_null_fp = fopen ("/dev/null", "w");
+      if (wr_null_fp == NULL)
+      {
+	perror ("netserver: opening for writing: /dev/null");
+	exit   (1);
+      }
+      if (close (STDERR_FILENO) == -1)
+      {
+	perror ("netserver: closing stderr file descriptor");
+	exit   (1);
+      }
+      if (dup (fileno (wr_null_fp))  == -1)
+      {
+	perror ("netserver: dupicate /dev/null write file descr. to stderr");
+	exit   (1);
+      }
  
 #ifndef NO_SETSID
       setsid();
@@ -613,7 +689,10 @@
 	      /* we have reaped all the children there are to reap at */
 	      /* the moment, so it is time to move on. raj 12/94 */
 #ifndef DONT_WAIT
+#ifdef NO_SETSID
+	      /* Only call "waitpid()" if "setsid()" is not used. */
 	      while(waitpid(-1, NULL, WNOHANG) > 0) { }
+#endif /* NO_SETSID */
 #endif /* DONT_WAIT */
 	      break;
 	    }

Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c	2006-04-21 17:11:13 UTC (rev 74)
+++ trunk/src/nettest_bsd.c	2006-05-24 17:32:06 UTC (rev 75)
@@ -138,9 +138,9 @@
 int first_burst_size=0;
 #endif /* WANT_FIRST_BURST */
 
-#if defined(HAVE_SENDFILE) && (defined(__linux) || defined(__SunOS_5_9))
+#if defined(HAVE_SENDFILE) && (defined(__linux) || defined(__sun__))
 #include <sys/sendfile.h>
-#endif /* HAVE_SENDFILE && (__linux || __SunOS_5_9 */
+#endif /* HAVE_SENDFILE && (__linux || __sun__) */
 
 
 
@@ -3326,13 +3326,19 @@
   struct  addrinfo *local_res;
   struct	sockaddr_in	server;
 
-#if defined(__linux) || defined(__SunOS_5_9)
+#if defined(__linux) || defined(__sun__)
   off_t     scratch_offset;   /* the linux sendfile() call will update
 				 the offset variable, which is
 				 something we do _not_ want to happen
 				 to the value in the send_ring! so, we
 				 have to use a scratch variable. */
-#endif /* __linux  || defined(__SunOS_5_9) */
+#endif /* __linux  || defined(__sun__) */
+#if defined (__sun__)
+   size_t  scratch_len;	/* the sun sendfilev() needs a place to 
+			   tell us how many bytes were written,
+			   even though it also returns the value */
+   sendfilevec_t sv;
+#endif /* __sun__ */
   
   struct	tcp_stream_request_struct	*tcp_stream_request;
   struct	tcp_stream_response_struct	*tcp_stream_response;
@@ -3659,12 +3665,21 @@
 			send_ring->length,
 			send_ring->hdtrl,
 			send_ring->flags)) != send_size)
-#elif defined(__linux)  || defined(__SunOS_5_9)
+#elif defined(__linux)
 	scratch_offset = send_ring->offset;
       if ((len=sendfile(send_socket, 
 			send_ring->fildes, 
 			&scratch_offset,   /* modified after the call! */
 			send_ring->length)) != send_size)
+#elif defined (__sun__)
+      /* We must call with SFV_NOWAIT and a large file size (>= 16MB) to
+	 get zero-copy, as well as compiling with  -D_LARGEFILE_SOURCE
+	  -D_FILE_OFFSET_BITS=64 */
+      sv.sfv_fd = send_ring->fildes;
+      sv.sfv_flag = SFV_NOWAIT;
+      sv.sfv_off = send_ring->offset;
+      sv.sfv_len =  send_ring->length;
+      if ((len = sendfilev(send_socket, &sv, 1, &scratch_len)) != send_size)
 #elif defined(__FreeBSD__)
 	/* so close to HP-UX and yet so far away... :) */
 	if ((sendfile(send_ring->fildes, 



More information about the netperf-dev mailing list