[netperf-dev] netperf2 commit notice r422 - in trunk: . doc doc/examples src src/missing src/missing/m4

raj at netperf.org raj at netperf.org
Mon Jul 11 14:58:41 PDT 2011


Author: raj
Date: 2011-07-11 14:58:41 -0700 (Mon, 11 Jul 2011)
New Revision: 422

Modified:
   trunk/Makefile.in
   trunk/aclocal.m4
   trunk/config.h.in
   trunk/configure
   trunk/configure.ac
   trunk/doc/Makefile.in
   trunk/doc/examples/Makefile.in
   trunk/src/Makefile.in
   trunk/src/missing/Makefile.in
   trunk/src/missing/m4/Makefile.in
   trunk/src/netcpu_procstat.c
   trunk/src/netlib.c
   trunk/src/netlib.h
   trunk/src/netserver.c
   trunk/src/netsh.c
   trunk/src/netsys_linux.c
   trunk/src/nettest_omni.c
Log:
massive re-write of src/netserver.c to clean out old spaghetti allow multiple listen sockets for control and run netserver without daemonizing or spawning children to avoid fork calls which may not sit well with various bypass libraries.  this has probably broken the Windows code and perhaps other platforms as well but it has been tested under linux

Modified: trunk/Makefile.in
===================================================================
--- trunk/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -277,7 +277,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \
@@ -302,7 +302,7 @@
 	fi; test -z "$$fail"
 
 $(RECURSIVE_CLEAN_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \
@@ -466,7 +466,8 @@
 	  fi; \
 	done
 	-test -n "$(am__skip_mode_fix)" \
-	|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+	|| find "$(distdir)" -type d ! -perm -755 \
+		-exec chmod u+rwx,go+rx {} \; -o \
 	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
@@ -511,17 +512,17 @@
 distcheck: dist
 	case '$(DIST_ARCHIVES)' in \
 	*.tar.gz*) \
-	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
-	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
 	*.tar.lzma*) \
-	  unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
 	*.tar.xz*) \
 	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
-	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac

Modified: trunk/aclocal.m4
===================================================================
--- trunk/aclocal.m4	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/aclocal.m4	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.11 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 # 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
@@ -13,8 +13,8 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],,
-[m4_warning([this file was generated for autoconf 2.64.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
+[m4_warning([this file was generated for autoconf 2.67.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
@@ -34,7 +34,7 @@
 [am__api_version='1.11'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11], [],
+m4_if([$1], [1.11.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -50,7 +50,7 @@
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11])dnl
+[AM_AUTOMAKE_VERSION([1.11.1])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

Modified: trunk/config.h.in
===================================================================
--- trunk/config.h.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/config.h.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -18,6 +18,9 @@
 /* Define to 1 if you have the `bzero' function. */
 #undef HAVE_BZERO
 
+/* Define to 1 if you have the `daemon' function. */
+#undef HAVE_DAEMON
+
 /* Define to 1 if you have the <endian.h> header file. */
 #undef HAVE_ENDIAN_H
 
@@ -163,6 +166,9 @@
 /* Define to 1 if you have the `sendfile' function. */
 #undef HAVE_SENDFILE
 
+/* Define to 1 if you have the `setsid' function. */
+#undef HAVE_SETSID
+
 /* Define to 1 if you have the <signal.h> header file. */
 #undef HAVE_SIGNAL_H
 
@@ -250,7 +256,7 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+/* Define to 1 if you have the <sys/wait.h> header file. */
 #undef HAVE_SYS_WAIT_H
 
 /* Define to 1 if you have the `toupper' function. */

Modified: trunk/configure
===================================================================
--- trunk/configure	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/configure	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,11 +1,13 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for netperf 2.5.0.
+# Generated by GNU Autoconf 2.67 for netperf 2.5.0.
 #
+#
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
 # Foundation, Inc.
 #
+#
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 ## -------------------- ##
@@ -314,7 +316,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -354,19 +356,19 @@
 fi # as_fn_arith
 
 
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $1" >&2
+  $as_echo "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -524,10 +526,11 @@
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-exec 7<&0 </dev/null 6>&1
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
 
 # Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
@@ -589,6 +592,7 @@
 # include <unistd.h>
 #endif"
 
+ac_header_list=
 ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
@@ -791,8 +795,9 @@
   fi
 
   case $ac_option in
-  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *)	ac_optarg=yes ;;
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
   esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
@@ -837,7 +842,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -863,7 +868,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
+      as_fn_error $? "invalid feature name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1067,7 +1072,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1083,7 +1088,7 @@
     ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
     expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
+      as_fn_error $? "invalid package name: $ac_useropt"
     ac_useropt_orig=$ac_useropt
     ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
     case $ac_user_opts in
@@ -1113,8 +1118,8 @@
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) as_fn_error "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information."
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
     ;;
 
   *=*)
@@ -1122,7 +1127,7 @@
     # Reject names that are not valid shell variable names.
     case $ac_envvar in #(
       '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
     esac
     eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
@@ -1140,13 +1145,13 @@
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error "missing argument to $ac_option"
+  as_fn_error $? "missing argument to $ac_option"
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
     *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
@@ -1169,7 +1174,7 @@
     [\\/$]* | ?:[\\/]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
-  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -1183,8 +1188,8 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used." >&2
+    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1199,9 +1204,9 @@
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error "working directory cannot be determined"
+  as_fn_error $? "working directory cannot be determined"
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error "pwd does not report name of working directory"
+  as_fn_error $? "pwd does not report name of working directory"
 
 
 # Find the source files, if location was not specified.
@@ -1240,11 +1245,11 @@
 fi
 if test ! -r "$srcdir/$ac_unique_file"; then
   test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
 fi
 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
 ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
 	pwd)`
 # When building in place, set srcdir=.
 if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1284,7 +1289,7 @@
       --help=short        display options specific to this package
       --help=recursive    display the short help of all the included packages
   -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking...' messages
+  -q, --quiet, --silent   do not print \`checking ...' messages
       --cache-file=FILE   cache test results in FILE [disabled]
   -C, --config-cache      alias for \`--cache-file=config.cache'
   -n, --no-create         do not create output files
@@ -1389,7 +1394,7 @@
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
   LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
 
@@ -1460,9 +1465,9 @@
 if $ac_init_version; then
   cat <<\_ACEOF
 netperf configure 2.5.0
-generated by GNU Autoconf 2.64
+generated by GNU Autoconf 2.67
 
-Copyright (C) 2009 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1507,7 +1512,7 @@
 	ac_retval=1
 fi
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
+  as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_compile
 
@@ -1553,7 +1558,7 @@
   # left behind by Apple's compiler.  We do this before executing the actions.
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
+  as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
 
@@ -1578,7 +1583,7 @@
     mv -f conftest.er1 conftest.err
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } >/dev/null && {
+  test $ac_status = 0; } > conftest.i && {
 	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        }; then :
@@ -1590,7 +1595,7 @@
     ac_retval=1
 fi
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
+  as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_cpp
 
@@ -1632,7 +1637,7 @@
 fi
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  return $ac_retval
+  as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_run
 
@@ -1644,10 +1649,10 @@
 ac_fn_c_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  if eval "test \"\${$3+set}\"" = set; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -1683,7 +1688,7 @@
 else
   ac_header_preproc=no
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
 $as_echo "$ac_header_preproc" >&6; }
 
@@ -1710,7 +1715,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -1732,7 +1737,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1763,7 +1768,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=no"
@@ -1816,7 +1821,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1884,7 +1889,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
 $as_echo_n "checking for $2.$3... " >&6; }
-if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$4+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1936,7 +1941,7 @@
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by netperf $as_me 2.5.0, which was
-generated by GNU Autoconf 2.64.  Invocation command line was
+generated by GNU Autoconf 2.67.  Invocation command line was
 
   $ $0 $@
 
@@ -2046,11 +2051,9 @@
   {
     echo
 
-    cat <<\_ASBOX
-## ---------------- ##
+    $as_echo "## ---------------- ##
 ## Cache variables. ##
-## ---------------- ##
-_ASBOX
+## ---------------- ##"
     echo
     # The following way of writing the cache mishandles newlines in values,
 (
@@ -2084,11 +2087,9 @@
 )
     echo
 
-    cat <<\_ASBOX
-## ----------------- ##
+    $as_echo "## ----------------- ##
 ## Output variables. ##
-## ----------------- ##
-_ASBOX
+## ----------------- ##"
     echo
     for ac_var in $ac_subst_vars
     do
@@ -2101,11 +2102,9 @@
     echo
 
     if test -n "$ac_subst_files"; then
-      cat <<\_ASBOX
-## ------------------- ##
+      $as_echo "## ------------------- ##
 ## File substitutions. ##
-## ------------------- ##
-_ASBOX
+## ------------------- ##"
       echo
       for ac_var in $ac_subst_files
       do
@@ -2119,11 +2118,9 @@
     fi
 
     if test -s confdefs.h; then
-      cat <<\_ASBOX
-## ----------- ##
+      $as_echo "## ----------- ##
 ## confdefs.h. ##
-## ----------- ##
-_ASBOX
+## ----------- ##"
       echo
       cat confdefs.h
       echo
@@ -2178,7 +2175,12 @@
 ac_site_file1=NONE
 ac_site_file2=NONE
 if test -n "$CONFIG_SITE"; then
-  ac_site_file1=$CONFIG_SITE
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
 elif test "x$prefix" != xNONE; then
   ac_site_file1=$prefix/share/config.site
   ac_site_file2=$prefix/etc/config.site
@@ -2189,18 +2191,22 @@
 for ac_site_file in "$ac_site_file1" "$ac_site_file2"
 do
   test "x$ac_site_file" = xNONE && continue
-  if test -r "$ac_site_file"; then
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file"
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5 ; }
   fi
 done
 
 if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special
-  # files actually), so we avoid doing that.
-  if test -f "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
 $as_echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
@@ -2214,6 +2220,9 @@
   >$cache_file
 fi
 
+as_fn_append ac_header_list " stdlib.h"
+as_fn_append ac_header_list " unistd.h"
+as_fn_append ac_header_list " sys/param.h"
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
@@ -2269,7 +2278,7 @@
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
 fi
 ## -------------------- ##
 ## Main body of script. ##
@@ -2290,16 +2299,22 @@
 # use the target version rather than host - one day we may want cross-compile
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
-  for ac_t in install-sh install.sh shtool; do
-    if test -f "$ac_dir/$ac_t"; then
-      ac_aux_dir=$ac_dir
-      ac_install_sh="$ac_aux_dir/$ac_t -c"
-      break 2
-    fi
-  done
+  if test -f "$ac_dir/install-sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f "$ac_dir/install.sh"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f "$ac_dir/shtool"; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
 done
 if test -z "$ac_aux_dir"; then
-  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
 fi
 
 # These three variables are undocumented and unsupported,
@@ -2313,7 +2328,7 @@
 
 # Make sure we can run config.sub.
 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 $as_echo_n "checking build system type... " >&6; }
@@ -2324,16 +2339,16 @@
 test "x$ac_build_alias" = x &&
   ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
 test "x$ac_build_alias" = x &&
-  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
 $as_echo "$ac_cv_build" >&6; }
 case $ac_cv_build in
 *-*-*) ;;
-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
 esac
 build=$ac_cv_build
 ac_save_IFS=$IFS; IFS='-'
@@ -2358,7 +2373,7 @@
   ac_cv_host=$ac_cv_build
 else
   ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
 fi
 
 fi
@@ -2366,7 +2381,7 @@
 $as_echo "$ac_cv_host" >&6; }
 case $ac_cv_host in
 *-*-*) ;;
-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
 esac
 host=$ac_cv_host
 ac_save_IFS=$IFS; IFS='-'
@@ -2391,7 +2406,7 @@
   ac_cv_target=$ac_cv_host
 else
   ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
 fi
 
 fi
@@ -2399,7 +2414,7 @@
 $as_echo "$ac_cv_target" >&6; }
 case $ac_cv_target in
 *-*-*) ;;
-*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
+*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;;
 esac
 target=$ac_cv_target
 ac_save_IFS=$IFS; IFS='-'
@@ -2528,11 +2543,11 @@
 '
 case `pwd` in
   *[\\\"\#\$\&\'\`$am_lf]*)
-    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+    as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;;
 esac
 case $srcdir in
   *[\\\"\#\$\&\'\`$am_lf\ \	]*)
-    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;;
 esac
 
 # Do `set' in a subshell so we don't clobber the current shell's
@@ -2554,7 +2569,7 @@
       # if, for instance, CONFIG_SHELL is bash and it inherits a
       # broken ls alias from the environment.  This has actually
       # happened.  Such a system could not be considered "sane".
-      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
 alias in your environment" "$LINENO" 5
    fi
 
@@ -2564,7 +2579,7 @@
    # Ok.
    :
 else
-   as_fn_error "newly created file is older than distributed files!
+   as_fn_error $? "newly created file is older than distributed files!
 Check your system clock" "$LINENO" 5
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -2736,6 +2751,7 @@
 
 fi
 
+  test -d ./--version && rmdir ./--version
   if test "${ac_cv_path_mkdir+set}" = set; then
     MKDIR_P="$ac_cv_path_mkdir -p"
   else
@@ -2743,7 +2759,6 @@
     # value for MKDIR_P within a source directory, because that will
     # break other packages using the cache if that directory is
     # removed, or if the value is a relative name.
-    test -d ./--version && rmdir ./--version
     MKDIR_P="$ac_install_sh -d"
   fi
 fi
@@ -2802,7 +2817,7 @@
 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
 set x ${MAKE-make}
 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
@@ -2810,7 +2825,7 @@
 all:
 	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
 case `${MAKE-make} -f conftest.make 2>/dev/null` in
   *@@@%%%=?*=@@@%%%*)
     eval ac_cv_prog_make_${ac_make}_set=yes;;
@@ -2844,7 +2859,7 @@
   am__isrc=' -I$(srcdir)'
   # test to see if srcdir already configured
   if test -f $srcdir/config.status; then
-    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
   fi
 fi
 
@@ -3210,8 +3225,8 @@
 
 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "no acceptable C compiler found in \$PATH
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5 ; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -3232,32 +3247,30 @@
 ... rest of stderr output deleted ...
          10q' conftest.err >conftest.er1
     cat conftest.er1 >&5
-    rm -f conftest.er1 conftest.err
   fi
+  rm -f conftest.er1 conftest.err
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
 done
 
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <stdio.h>
+
 int
 main ()
 {
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
 
   ;
   return 0;
 }
 _ACEOF
 ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out"
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
 
 # The possible output files:
@@ -3319,62 +3332,28 @@
 else
   ac_file=''
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
 if test -z "$ac_file"; then :
-  $as_echo "$as_me: failed program was:" >&5
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ as_fn_set_status 77
-as_fn_error "C compiler cannot create executables
-See \`config.log' for more details." "$LINENO" 5; }; }
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5 ; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
 ac_exeext=$ac_cv_exeext
 
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
-  if { ac_try='./$ac_file'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
 $as_echo_n "checking for suffix of executables... " >&6; }
 if { { ac_try="$ac_link"
@@ -3404,16 +3383,75 @@
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5 ; }
 fi
-rm -f conftest$ac_cv_exeext
+rm -f conftest conftest$ac_cv_exeext
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
 $as_echo "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5 ; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
 $as_echo_n "checking for suffix of object files... " >&6; }
 if test "${ac_cv_objext+set}" = set; then :
@@ -3456,8 +3494,8 @@
 
 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5 ; }
 fi
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
@@ -4126,7 +4164,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -4142,11 +4180,11 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
   break
 fi
@@ -4185,7 +4223,7 @@
   # Broken: fails on valid input.
 continue
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
   # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
@@ -4201,18 +4239,18 @@
 ac_preproc_ok=:
 break
 fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
 
 done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then :
 
 else
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5 ; }
 fi
 
 ac_ext=c
@@ -4273,7 +4311,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_GREP"; then
-    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_GREP=$GREP
@@ -4339,7 +4377,7 @@
   done
 IFS=$as_save_IFS
   if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
   ac_cv_path_EGREP=$EGREP
@@ -4505,6 +4543,8 @@
 
 fi
 
+
+# lets keep this in some semblence of alphabetical order
 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
 		  inttypes.h stdint.h unistd.h
@@ -4512,8 +4552,7 @@
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
 "
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -4523,12 +4562,11 @@
 done
 
 
-for ac_header in arpa/inet.h endian.h errno.h fcntl.h limits.h malloc.h netdb.h netinet/in.h signal.h stdlib.h string.h strings.h sys/ioctl.h sys/mman.h sys/param.h sys/socket.h sys/time.h unistd.h ifaddrs.h sys/ipc.h sys/sockio.h sys/sysinfo.h syscall.h netinet/sctp.h linux/tcp.h
+for ac_header in arpa/inet.h endian.h errno.h fcntl.h ifaddrs.h limits.h linux/tcp.h malloc.h netdb.h netinet/in.h netinet/sctp.h signal.h stdlib.h string.h strings.h syscall.h sys/ioctl.h sys/mman.h sys/param.h sys/socket.h sys/stat.h sys/time.h sys/wait.h sys/ipc.h sys/sockio.h sys/sysinfo.h stdlib.h unistd.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -5349,8 +5387,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -5548,12 +5585,15 @@
 fi
 
 # AC_FUNC_MALLOC
-for ac_header in stdlib.h unistd.h
+
+
+
+  for ac_header in $ac_header_list
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -5562,6 +5602,13 @@
 
 done
 
+
+
+
+
+
+
+
 for ac_func in getpagesize
 do :
   ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize"
@@ -5618,11 +5665,6 @@
 
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
-/* Assume that all systems that can run configure have sys/param.h.  */
-# ifndef HAVE_SYS_PARAM_H
-#  define HAVE_SYS_PARAM_H 1
-# endif
-
 # ifdef _SC_PAGESIZE
 #  define getpagesize() sysconf(_SC_PAGESIZE)
 # else /* no _SC_PAGESIZE */
@@ -5657,8 +5699,9 @@
 main ()
 {
   char *data, *data2, *data3;
+  const char *cdata2;
   int i, pagesize;
-  int fd;
+  int fd, fd2;
 
   pagesize = getpagesize ();
 
@@ -5671,27 +5714,41 @@
   umask (0);
   fd = creat ("conftest.mmap", 0600);
   if (fd < 0)
-    return 1;
+    return 2;
   if (write (fd, data, pagesize) != pagesize)
-    return 1;
+    return 3;
   close (fd);
 
+  /* Next, check that the tail of a page is zero-filled.  File must have
+     non-zero length, otherwise we risk SIGBUS for entire page.  */
+  fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
+  if (fd2 < 0)
+    return 4;
+  cdata2 = "";
+  if (write (fd2, cdata2, 1) != 1)
+    return 5;
+  data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
+  if (data2 == MAP_FAILED)
+    return 6;
+  for (i = 0; i < pagesize; ++i)
+    if (*(data2 + i))
+      return 7;
+  close (fd2);
+  if (munmap (data2, pagesize))
+    return 8;
+
   /* Next, try to mmap the file at a fixed address which already has
      something else allocated at it.  If we can, also make sure that
      we see the same garbage.  */
   fd = open ("conftest.mmap", O_RDWR);
   if (fd < 0)
-    return 1;
-  data2 = (char *) malloc (2 * pagesize);
-  if (!data2)
-    return 1;
-  data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1);
+    return 9;
   if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
 		     MAP_PRIVATE | MAP_FIXED, fd, 0L))
-    return 1;
+    return 10;
   for (i = 0; i < pagesize; ++i)
     if (*(data + i) != *(data2 + i))
-      return 1;
+      return 11;
 
   /* Finally, make sure that changes to the mapped area do not
      percolate back to the file as seen by read().  (This is a bug on
@@ -5700,12 +5757,12 @@
     *(data2 + i) = *(data2 + i) + 1;
   data3 = (char *) malloc (pagesize);
   if (!data3)
-    return 1;
+    return 12;
   if (read (fd, data3, pagesize) != pagesize)
-    return 1;
+    return 13;
   for (i = 0; i < pagesize; ++i)
     if (*(data + i) != *(data3 + i))
-      return 1;
+      return 14;
   close (fd);
   return 0;
 }
@@ -5727,14 +5784,13 @@
 $as_echo "#define HAVE_MMAP 1" >>confdefs.h
 
 fi
-rm -f conftest.mmap
+rm -f conftest.mmap conftest.txt
 
 for ac_header in sys/select.h sys/socket.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -5811,7 +5867,7 @@
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
-  as_fn_error "cannot check setpgrp when cross compiling" "$LINENO" 5
+  as_fn_error $? "cannot check setpgrp when cross compiling" "$LINENO" 5
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -5881,12 +5937,11 @@
 # AC_FUNC_STAT
 # remove pstat_getdynamic (at least for now) since we don't do
 # anything conditional with the check anyway...
-for ac_func in alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname toupper
+for ac_func in alarm bzero daemon gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select setsid socket sqrt strcasecmp strchr strstr strtoul uname toupper
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -5902,8 +5957,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -5974,8 +6028,7 @@
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
@@ -6007,7 +6060,7 @@
 		use_histogram=false
 		;;
 	*)
-		as_fn_error "--enable-histogram takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-histogram takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6049,7 +6102,7 @@
 		use_dirty=false
 		;;
 	*)
-		as_fn_error "--enable-dirty takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-dirty takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6092,7 +6145,7 @@
 		use_demo=false
 		;;
 	*)
-		as_fn_error "--enable-demo takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-demo takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6134,7 +6187,7 @@
 		use_unixdomain=false
 		;;
      *)
-		as_fn_error "--enable-unixdomain takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-unixdomain takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6176,7 +6229,7 @@
 		use_dlpi=false
 		;;
      *)
-		as_fn_error "--enable-dlpi takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-dlpi takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6218,7 +6271,7 @@
 		use_dccp=false
 		;;
      *)
-		as_fn_error "--enable-dccp takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-dccp takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6260,7 +6313,7 @@
 		use_omni=true
 		;;
      *)
-		as_fn_error "--enable-omni takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-omni takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6306,7 +6359,7 @@
 		use_xti=false
 		;;
      *)
-		as_fn_error "--enable-xti takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-xti takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6394,7 +6447,7 @@
 		use_sdp=false
 		;;
      *)
-		as_fn_error "--enable-sdp takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-sdp takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6491,7 +6544,7 @@
 		use_exs=false
 		;;
      *)
-		as_fn_error "--enable-exs takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-exs takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6609,7 +6662,7 @@
 		use_sctp=false
 		;;
 	*)
-		as_fn_error "--enable-sctp takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-sctp takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6654,7 +6707,7 @@
 		use_intervals=false
 		;;
 	*)
-		as_fn_error "--enable-intervals takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-intervals takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6696,7 +6749,7 @@
 		use_spin=false
 		;;
 	*)
-		as_fn_error "--enable-spin takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-spin takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -6741,7 +6794,7 @@
 		use_burst=true
 		;;
 	*)
-		as_fn_error "--enable-burst takes yes or no" "$LINENO" 5
+		as_fn_error $? "--enable-burst takes yes or no" "$LINENO" 5
 		;;
 esac
 
@@ -7143,7 +7196,7 @@
 		use_cpuutil=false
 		;;
 	*)
-		as_fn_error "--enable-cpuutil takes kstat, kstat10, looper, osx, perfstat, procstat, pstat, pstatnew, sysctl or none" "$LINENO" 5
+		as_fn_error $? "--enable-cpuutil takes kstat, kstat10, looper, osx, perfstat, procstat, pstat, pstatnew, sysctl or none" "$LINENO" 5
 		;;
 esac
 
@@ -7201,7 +7254,7 @@
 		use_rtlookup=false
 		;;
 	*)
-		as_fn_error "--enable-rtlookup takes rtmget, rtnetlink or none" "$LINENO" 5
+		as_fn_error $? "--enable-rtlookup takes rtmget, rtnetlink or none" "$LINENO" 5
 		;;
 esac
 
@@ -7382,7 +7435,7 @@
 		use_slotlookup=false
 		;;
 	*)
-		as_fn_error "--enable-slotlookup takes linux or none" "$LINENO" 5
+		as_fn_error $? "--enable-slotlookup takes linux or none" "$LINENO" 5
 		;;
 esac
 
@@ -7468,7 +7521,7 @@
 		use_seclookup=false
 		;;
 	*)
-		as_fn_error "--enable-seclookup takes linux or none" "$LINENO" 5
+		as_fn_error $? "--enable-seclookup takes linux or none" "$LINENO" 5
 		;;
 esac
 
@@ -7522,7 +7575,7 @@
 		use_drvlookup=false
 		;;
 	*)
-		as_fn_error "--enable-drvlookup takes ethtool or none" "$LINENO" 5
+		as_fn_error $? "--enable-drvlookup takes ethtool or none" "$LINENO" 5
 		;;
 esac
 
@@ -7792,7 +7845,7 @@
 		use_syslookup=false
 		;;
 	*)
-		as_fn_error "--enable-syslookup takes hpux11i, linux or none" "$LINENO" 5
+		as_fn_error $? "--enable-syslookup takes hpux11i, linux or none" "$LINENO" 5
 		;;
 esac
 
@@ -7888,6 +7941,7 @@
 
 ac_libobjs=
 ac_ltlibobjs=
+U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -7911,15 +7965,15 @@
 fi
 
 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
-  as_fn_error "conditional \"AMDEP\" was never defined.
+  as_fn_error $? "conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 if test -z "${NEED_LIBCOMPAT_TRUE}" && test -z "${NEED_LIBCOMPAT_FALSE}"; then
-  as_fn_error "conditional \"NEED_LIBCOMPAT\" was never defined.
+  as_fn_error $? "conditional \"NEED_LIBCOMPAT\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 
@@ -8069,19 +8123,19 @@
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
 
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
 as_fn_error ()
 {
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
   fi
-  $as_echo "$as_me: error: $1" >&2
+  $as_echo "$as_me: error: $2" >&2
   as_fn_exit $as_status
 } # as_fn_error
 
@@ -8277,7 +8331,7 @@
       test -d "$as_dir" && break
     done
     test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
 
 
 } # as_fn_mkdir_p
@@ -8331,7 +8385,7 @@
 # values after options handling.
 ac_log="
 This file was extended by netperf $as_me 2.5.0, which was
-generated by GNU Autoconf 2.64.  Invocation command line was
+generated by GNU Autoconf 2.67.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -8371,6 +8425,7 @@
 
   -h, --help       print this help, then exit
   -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
   -q, --quiet, --silent
                    do not print progress messages
   -d, --debug      don't remove temporary files
@@ -8393,12 +8448,13 @@
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 netperf config.status 2.5.0
-configured by $0, generated by GNU Autoconf 2.64,
-  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+configured by $0, generated by GNU Autoconf 2.67,
+  with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2009 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -8416,11 +8472,16 @@
 while test $# != 0
 do
   case $1 in
-  --*=*)
+  --*=?*)
     ac_option=`expr "X$1" : 'X\([^=]*\)='`
     ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
     ac_shift=:
     ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
   *)
     ac_option=$1
     ac_optarg=$2
@@ -8434,12 +8495,15 @@
     ac_cs_recheck=: ;;
   --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
     $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
   --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
     case $ac_optarg in
     *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
@@ -8452,7 +8516,7 @@
     ac_need_defaults=false;;
   --he | --h)
     # Conflict between --help and --header
-    as_fn_error "ambiguous option: \`$1'
+    as_fn_error $? "ambiguous option: \`$1'
 Try \`$0 --help' for more information.";;
   --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
@@ -8461,7 +8525,7 @@
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) as_fn_error "unrecognized option: \`$1'
+  -*) as_fn_error $? "unrecognized option: \`$1'
 Try \`$0 --help' for more information." ;;
 
   *) as_fn_append ac_config_targets " $1"
@@ -8526,7 +8590,7 @@
     "doc/examples/Makefile") CONFIG_FILES="$CONFIG_FILES doc/examples/Makefile" ;;
     "netperf.spec") CONFIG_FILES="$CONFIG_FILES netperf.spec" ;;
 
-  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
   esac
 done
 
@@ -8564,7 +8628,7 @@
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -8581,7 +8645,7 @@
 fi
 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\r'
+  ac_cs_awk_cr='\\r'
 else
   ac_cs_awk_cr=$ac_cr
 fi
@@ -8595,18 +8659,18 @@
   echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
   echo "_ACEOF"
 } >conf$$subs.sh ||
-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   . ./conf$$subs.sh ||
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
 
   ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
   if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -8628,7 +8692,7 @@
 t delim
 :nl
 h
-s/\(.\{148\}\).*/\1/
+s/\(.\{148\}\)..*/\1/
 t more1
 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
 p
@@ -8642,7 +8706,7 @@
 t nl
 :delim
 h
-s/\(.\{148\}\).*/\1/
+s/\(.\{148\}\)..*/\1/
 t more2
 s/["\\]/\\&/g; s/^/"/; s/$/"/
 p
@@ -8695,20 +8759,28 @@
 else
   cat
 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
 _ACEOF
 
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
 # trailing colons and then remove the whole line if VPATH becomes empty
 # (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[	 ]*\):*/\1/
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
 s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
 s/^[^=]*=[	 ]*$//
 }'
 fi
@@ -8736,7 +8808,7 @@
   if test -z "$ac_t"; then
     break
   elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
   else
     ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
@@ -8821,7 +8893,7 @@
 _ACAWK
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
 fi # test -n "$CONFIG_HEADERS"
 
 
@@ -8834,7 +8906,7 @@
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
@@ -8862,7 +8934,7 @@
 	   [\\/$]*) false;;
 	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
 	   esac ||
-	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
       esac
       case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
       as_fn_append ac_file_inputs " '$ac_f'"
@@ -8889,7 +8961,7 @@
 
     case $ac_tag in
     *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5  ;;
     esac
     ;;
   esac
@@ -9026,22 +9098,22 @@
 $ac_datarootdir_hack
 "
 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
   { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&5
+which seems to be undefined.  Please make sure it is defined" >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&2;}
+which seems to be undefined.  Please make sure it is defined" >&2;}
 
   rm -f "$tmp/stdin"
   case $ac_file in
   -) cat "$tmp/out" && rm -f "$tmp/out";;
   *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
   esac \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
   :H)
   #
@@ -9052,19 +9124,19 @@
       $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
     } >"$tmp/config.h" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
     if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
       mv "$tmp/config.h" "$ac_file" \
-	|| as_fn_error "could not create $ac_file" "$LINENO" 5
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error "could not create -" "$LINENO" 5
+      || as_fn_error $? "could not create -" "$LINENO" 5
   fi
 # Compute "$ac_file"'s index in $config_headers.
 _am_arg="$ac_file"
@@ -9214,7 +9286,7 @@
 ac_clean_files=$ac_clean_files_save
 
 test $ac_write_fail = 0 ||
-  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
 
 # configure is writing to config.log, and then calls config.status.
@@ -9235,7 +9307,7 @@
   exec 5>>config.log
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit $?
+  $ac_cs_success || as_fn_exit 1
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/configure.ac	2011-07-11 21:58:41 UTC (rev 422)
@@ -36,8 +36,10 @@
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h endian.h errno.h fcntl.h limits.h malloc.h netdb.h netinet/in.h signal.h stdlib.h string.h strings.h sys/ioctl.h sys/mman.h sys/param.h sys/socket.h sys/time.h unistd.h ifaddrs.h sys/ipc.h sys/sockio.h sys/sysinfo.h syscall.h netinet/sctp.h linux/tcp.h])
 
+# lets keep this in some semblence of alphabetical order
+AC_CHECK_HEADERS([arpa/inet.h endian.h errno.h fcntl.h ifaddrs.h limits.h linux/tcp.h malloc.h netdb.h netinet/in.h netinet/sctp.h signal.h stdlib.h string.h strings.h syscall.h sys/ioctl.h sys/mman.h sys/param.h sys/socket.h sys/stat.h sys/time.h sys/wait.h sys/ipc.h sys/sockio.h sys/sysinfo.h stdlib.h unistd.h])
+
 # Some platforms require these.  There may be a better way.
 AC_HAVE_LIBRARY(socket)
 if test "$ac_cv_lib_socket_main" = yes ; then
@@ -75,7 +77,7 @@
 # AC_FUNC_STAT
 # remove pstat_getdynamic (at least for now) since we don't do
 # anything conditional with the check anyway...
-AC_CHECK_FUNCS([alarm bzero gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select socket sqrt strcasecmp strchr strstr strtoul uname toupper])
+AC_CHECK_FUNCS([alarm bzero daemon gethostbyname gethrtime gettimeofday inet_ntoa memset memcpy munmap select setsid socket sqrt strcasecmp strchr strstr strtoul uname toupper])
 
 #AC_CONFIG_SUBDIRS(src/missing)
 

Modified: trunk/doc/Makefile.in
===================================================================
--- trunk/doc/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/doc/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -462,7 +462,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \
@@ -487,7 +487,7 @@
 	fi; test -z "$$fail"
 
 $(RECURSIVE_CLEAN_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \

Modified: trunk/doc/examples/Makefile.in
===================================================================
--- trunk/doc/examples/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/doc/examples/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,

Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -370,7 +370,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \
@@ -395,7 +395,7 @@
 	fi; test -z "$$fail"
 
 $(RECURSIVE_CLEAN_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \

Modified: trunk/src/missing/Makefile.in
===================================================================
--- trunk/src/missing/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/missing/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -287,7 +287,7 @@
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
 $(RECURSIVE_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \
@@ -312,7 +312,7 @@
 	fi; test -z "$$fail"
 
 $(RECURSIVE_CLEAN_TARGETS):
-	@failcom='exit 1'; \
+	@fail= failcom='exit 1'; \
 	for f in x $$MAKEFLAGS; do \
 	  case $$f in \
 	    *=* | --[!k]*);; \

Modified: trunk/src/missing/m4/Makefile.in
===================================================================
--- trunk/src/missing/m4/Makefile.in	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/missing/m4/Makefile.in	2011-07-11 21:58:41 UTC (rev 422)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,

Modified: trunk/src/netcpu_procstat.c
===================================================================
--- trunk/src/netcpu_procstat.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netcpu_procstat.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -93,7 +93,7 @@
     proc_stat_buflen = N_CPU_LINES (lib_num_loc_cpus) * CPU_LINE_LENGTH;
     if (debug) {
       fprintf(where,
-	      "lib_num_loc_cpus %d lines %d CPU_LINE_LENGTH %d proc_stat_buflen %d\n",
+	      "lib_num_loc_cpus %d lines %d CPU_LINE_LENGTH %lu proc_stat_buflen %d\n",
 	      lib_num_loc_cpus,
 	      N_CPU_LINES(lib_num_loc_cpus),
 	      CPU_LINE_LENGTH,
@@ -140,7 +140,7 @@
     proc_stat_buflen = N_CPU_LINES (lib_num_loc_cpus) * CPU_LINE_LENGTH;
     if (debug) {
       fprintf(where,
-	      "calibrate: lib_num_loc_cpus %d lines %d CPU_LINE_LENGTH %d proc_stat_buflen %d\n",
+	      "calibrate: lib_num_loc_cpus %d lines %d CPU_LINE_LENGTH %lu proc_stat_buflen %d\n",
 	      lib_num_loc_cpus,
 	      N_CPU_LINES(lib_num_loc_cpus),
 	      CPU_LINE_LENGTH,

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netlib.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -1149,10 +1149,9 @@
   alarm(0);
 #else
   /* at some point we may need some win32 equivalent */
-  	if (hAlarm != (HANDLE) INVALID_HANDLE_VALUE)
-	{
-		SetEvent(hAlarm);
-	}
+  if (hAlarm != (HANDLE) INVALID_HANDLE_VALUE) {
+    SetEvent(hAlarm);
+  }
 #endif /* WIN32 */
 
 }
@@ -1298,7 +1297,7 @@
 {
   int i;
 
-  where            = stdout;
+  where = stdout;
 
   request_array = (int *)(&netperf_request);
   response_array = (int *)(&netperf_response);
@@ -2503,7 +2502,7 @@
    connection. the first two ints, which are before the test-specific
    portion are always converted. raj 2008-02-05 */
 
-void
+int
 recv_request_n(int n)
 {
 int     tot_bytes_recvd,
@@ -2559,17 +2558,15 @@
   
   if (bytes_recvd == 0) {
     /* the remote has shutdown the control connection, we should shut
-       it down as well and exit */
+       it down as well and return */
     if (debug) {
       fprintf(where,
 	      "recv_request: remote requested shutdown of control\n");
       fflush(where);
     }
     
-    if (netlib_control != INVALID_SOCKET) {
-      shutdown_control();
-    }
-    exit(0);
+    close(server_sock);
+    return 0;
   }
 
   if (tot_bytes_recvd < buflen) {
@@ -2610,11 +2607,11 @@
  /*                                                                     */
  /***********************************************************************/
 
-void
+int
 recv_request()
 {
 
-  recv_request_n(-1);
+  return recv_request_n(-1);
 
 }
 

Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netlib.h	2011-07-11 21:58:41 UTC (rev 422)
@@ -496,11 +496,11 @@
 extern  void    send_request();
 extern  void    recv_response();
 extern  void    send_response();
-extern  void    recv_request();
+extern  int     recv_request();
 extern  void    send_request_n(int n);  /* convert only the first N ints */
 extern  void    recv_response_n(int n); /* of the test-specific data via */
 extern  void    send_response_n(int n); /* htonl/ntonl as required */
-extern  void    recv_request_n(int n);
+extern  int     recv_request_n(int n);
 extern  void    dump_request();
 extern  void    dump_addrinfo(FILE *dumploc, struct addrinfo *info,
 			      char *host, char *port, int family);

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netserver.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -47,24 +47,7 @@
 char	netserver_id[]="\
 @(#)netserver.c (c) Copyright 1993-2011 Hewlett-Packard Co. Version 2.5.0";
 
- /***********************************************************************/
- /*									*/
- /*	netserver.c							*/
- /*									*/
- /*	This is the server side code for the netperf test package. It	*/
- /* will operate either stand-alone, or as a child of inetd. In this	*/
- /* way, we insure that it can be installed on systems with or without	*/
- /* root permissions (editing inetd.conf). Essentially, this code is	*/
- /* the analog to the netsh.c code.					*/
- /*									*/
- /***********************************************************************/
 
-
-/************************************************************************/
-/*									*/
-/*	Global include files						*/
-/*									*/
-/************************************************************************/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -75,54 +58,76 @@
 # endif
 # include <string.h>
 #endif
+
 #if HAVE_STRINGS_H
 # include <strings.h>
 #endif
+
 #if HAVE_LIMITS_H
 # include <limits.h>
 #endif
-#include <sys/types.h>
-#include <stdio.h>
-#ifndef WIN32
+
+#if HAVE_SYS_IPC_H
+#include <sys/ipc.h>
+#endif
+
+#if HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#if HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if HAVE_ERRNO_H
 #include <errno.h>
+#endif
+
+#if HAVE_SIGNAL_H
 #include <signal.h>
 #endif
-#if !defined(WIN32) && !defined(__VMS) && !defined(MSDOS)
-#include <sys/ipc.h>
-#endif /* !defined(WIN32) && !defined(__VMS) && !defined(MSDOS) */
-#include <fcntl.h>
+
 #ifdef WIN32
 #include <time.h>
 #include <winsock2.h>
-#define netperf_socklen_t socklen_t
-/* we need to find some other way to decide to include ws2 */
-/* if you are trying to compile on Windows 2000 or NT 4 you will */
-/* probably have to define DONT_IPV6 */
-#ifndef DONT_IPV6
+
+#if HAVE_WS2TCPIP.h
 #include <ws2tcpip.h>
-#endif  /* DONT_IPV6 */
+#endif
+
 #include <windows.h>
+
 #define strdup _strdup
-#define sleep(x) Sleep((x)*1000)
-#else
-#ifndef MPE
-#include <sys/time.h>
-#endif /* MPE */
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <unistd.h>
-#ifndef DONT_WAIT
-#include <sys/wait.h>
-#endif /* DONT_WAIT */
+#define sleep(x) SLEEP((x)*1000)
 #endif /* WIN32 */
-#include <stdlib.h>
-#ifdef __VMS
-#include <tcpip$inetdef.h> 
-#include <unixio.h> 
-#endif /* __VMS */
+
+/* unconditional system includes */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+/* netperf includes */
 #include "netlib.h"
 #include "nettest_bsd.h"
 
@@ -140,55 +145,462 @@
 
 #include "netsh.h"
 
-#ifndef DEBUG_LOG_FILE
+#ifndef DEBUG_LOG_FILE_DIR
 #if defined(WIN32)
-#define DEBUG_LOG_FILE "c:\\temp\\netperf.debug"
+#define DEBUG_LOG_FILE_DIR "c:\\temp\\"
 #elif defined(ANDROID)
-#define DEBUG_LOG_FILE "/data/local/tmp/netperf.debug"
+#define DEBUG_LOG_FILE_DIR "/data/local/tmp/"
 #else
-#define DEBUG_LOG_FILE "/tmp/netperf.debug"
+#define DEBUG_LOG_FILE_DIR "/tmp/"
 #endif
-#endif /* DEBUG_LOG_FILE */
+#endif /* DEBUG_LOG_FILE_DIR */
 
- /* some global variables */
+#ifndef DEBUG_LOG_FILE
+#define DEBUG_LOG_FILE DEBUG_LOG_FILE_DIR"netserver.debug"
+#endif
 
-FILE	*afp;
-char    listen_port[10];
+
+char     listen_port[10];
+
+struct listen_elt {
+  SOCKET fd;
+  struct listen_elt *next;
+};
+
+struct listen_elt *listen_list = NULL;
+
+SOCKET   server_control;
+
+int      child;   /* are we the child of inetd or a parent netserver?
+		     */
+int      netperf_daemon;
+int      daemon_parent = 0;
+int      not_inetd;
+int      want_daemonize;
+int      spawn_on_accept;
+
 extern	char	*optarg;
 extern	int	optind, opterr;
 
-#ifndef WIN32
-#define SERVER_ARGS "dhL:n:p:v:V46"
+static void
+init_netserver_globals() {
+
+#if defined(__VMS) || defined(VMWARE_UW)
+  spawn_on_accept = 0;
+  want_daemonize = 0;
 #else
-#define SERVER_ARGS "dhL:n:p:v:V46I:i:"
-#endif
+  spawn_on_accept = 1;
+#if defined(WIN32)
+  /* we only know how to spawn in WIN32, not daemonize */
+  want_daemonize = 0;
+#else
+  want_daemonize = 1;
+#endif /* WIN32 */
+#endif /* __VMS || VMWARE_UW */
 
-/* perhaps one day we will use this as part of only opening a debug
-   log file if debug is set, of course we have to be wary of the base
-   use of "where" and so probably always need "where" pointing
-   "somewhere" or other. */
+  child = 0;
+  not_inetd = 0;
+  netperf_daemon = 0;
+}
+
+/* it is important that set_server_sock() be called before this
+   routine as we depend on the control socket being dup()ed out of the
+   way when we go messing about with the streams. */
 void
 open_debug_file() 
 {
-#ifndef WIN32
-#ifndef PATH_MAX
+#if !defined(PATH_MAX)
 #define PATH_MAX MAX_PATH
 #endif
+
+#if !defined WIN32
+#define NETPERF_NULL "/dev/null"
+#else
+#define NETPERF_NULL "nul"
+#endif
+
   char FileName[PATH_MAX];   /* for opening the debug log file */
-  strcpy(FileName, DEBUG_LOG_FILE);
+  int  fp;
 
   if (where != NULL) fflush(where);
 
-  snprintf(&FileName[strlen(FileName)], sizeof(FileName) - strlen(FileName), "_%d", getpid());
+  snprintf(FileName,
+	   sizeof(FileName),
+	   "%s_%d",
+	   DEBUG_LOG_FILE,
+	   getpid());
   if ((where = fopen(FileName, "w")) == NULL) {
     perror("netserver: debug file");
     exit(1);
   }
-
+#ifndef WIN32
   chmod(FileName,0644);
 #endif
 
+  /* we want to redirect the io streams accordingly and we certainly
+     rely on file descriptors ending-up in the correct place. this
+     may look a little odd, but I believe it is the amalgam of what
+     was being done under both *nix and Windows and I am looking to
+     minimize the #ifdefs. raj 2011-07-11 */
+
+  fp = fileno(stdin);
+  fclose(stdin);
+  close(fp);
+  if ((stdin = fopen(NETPERF_NULL,"r")) == NULL) {
+    fprintf(where,
+	    "%s: reopening of stdin pointed at %s failed: %s (errno %d)\n",
+	    __FUNCTION__,
+	    NETPERF_NULL,
+	    strerror(errno),
+	    errno);
+    fflush(where);
+    exit(1);
+  }
+
+  fp = fileno(stdout);
+  fclose(stdout);
+  close(fp);
+  if ((stdin = fopen(FileName, "w")) == NULL) {
+    fprintf(where,
+	    "%s: redirecting stdout to %s failed: %s (errno %d)\n",
+	    __FUNCTION__,
+	    FileName,
+	    strerror(errno),
+	    errno);
+    fflush(where);
+    exit(1);
+  }
+
+
+  fp = fileno(stderr);
+  fclose(stderr);
+  close(fp);
+  if ((stdin = fopen(FileName, "w")) == NULL) {
+    fprintf(where,
+	    "%s: redirecting stderr to %s failed: %s (errno %d)\n",
+	    __FUNCTION__,
+	    FileName,
+	    strerror(errno),
+	    errno);
+    fflush(where);
+    exit(1);
+  }
 }
+
+/* so, either we are a child of inetd in which case server_sock should
+   be stdin, or we are a child of a netserver parent.  there will be
+   logic here for all of it, including Windows. it is important that
+   this be called before open_debug_file() */
+
+void
+set_server_sock() {
+
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
+
+#ifdef WIN32
+  server_sock = (SOCKET)GetStdHandle(STD_INPUT_HANDLE);
+#elif !defined(__VMS)
+  if (server_sock != INVALID_SOCKET) {
+    fprintf(where,"Yo, Iz ain't invalid!\n");
+    fflush(where);
+    exit(1);
+  }
+
+  /* we dup this to up the reference count so when we do redirection
+     of the io streams we don't accidentally toast the control
+     connection in the case of our being a child of inetd. */
+  server_sock = dup(0);
+
+#else
+  if ((server_sock = 
+       socket(TCPIP$C_AUXS, SOCK_STREAM, 0)) == INVALID_SOCKET) {
+    fprintf(stderr,
+	    "%s: failed to grab aux server socket: %s (errno %s)\n",
+	    __FUNCTION__,
+	    strerror(errno),
+	    errno);
+    fflush(stderr);
+    exit(1);
+  }
+#endif
+
+}
+
+
+void
+create_listens(char hostname[], char port[], int af) {
+
+  struct addrinfo hints;
+  struct addrinfo *local_res;
+  struct addrinfo *local_res_temp;
+  int count, error, not_listening;
+  int on = 1;
+  SOCKET temp_socket;
+  struct listen_elt *temp_elt;
+
+  if (debug) {
+    fprintf(stderr,
+	    "%s: called with host '%s' port '%s' family %s(%d)\n",
+	    __FUNCTION__,
+            hostname,
+	    port,
+	    inet_ftos(af),
+            af);
+    fflush(stderr);
+  }
+ memset(&hints,0,sizeof(hints));
+  hints.ai_family = af;
+  hints.ai_socktype = SOCK_STREAM;
+  hints.ai_protocol = IPPROTO_TCP;
+  hints.ai_flags = AI_PASSIVE;
+
+  count = 0;
+  do {
+    error = getaddrinfo((char *)hostname,
+                        (char *)port,
+                        &hints,
+                        &local_res);
+    count += 1;
+    if (error == EAI_AGAIN) {
+      if (debug) {
+        fprintf(stderr,
+		"%s: Sleeping on getaddrinfo EAI_AGAIN\n",
+		__FUNCTION__);
+        fflush(stderr);
+      }
+      sleep(1);
+    }
+  } while ((error == EAI_AGAIN) && (count <= 5));
+
+  if ((error) && (debug)) {
+    fprintf(stderr,
+	    "%s: could not resolve remote '%s' port '%s' af %d\n"
+	    "\tgetaddrinfo returned %s (%d)\n",
+	    __FUNCTION__,
+	    hostname,
+	    port,
+	    af,
+	    gai_strerror(error),
+	    error);
+
+  }
+
+  if (debug) {
+    dump_addrinfo(stderr, local_res, hostname, port, af);
+  }
+
+  local_res_temp = local_res;
+
+  while (local_res_temp != NULL) {
+
+    temp_socket = socket(local_res_temp->ai_family,SOCK_STREAM,0);
+
+    if (temp_socket == INVALID_SOCKET) {
+      fprintf(stderr,
+	      "%s could not allocate a socket: %s (errno %d)\n",
+	      __FUNCTION__,
+	      strerror(errno),
+	      errno);
+      fflush(stderr);
+      exit(-1);
+    }
+
+    /* happiness and joy, keep going */
+    if (setsockopt(temp_socket,
+		   SOL_SOCKET, 
+		   SO_REUSEADDR, 
+		   (char *)&on , 
+		   sizeof(on)) == SOCKET_ERROR) {
+      if (debug) {
+	fprintf(stderr,
+		"%s: warning: could not set SO_REUSEADDR: %s (errno %d)\n",
+		__FUNCTION__,
+		strerror(errno),
+		errno);
+	fflush(stderr);
+      }
+    }
+    /* still happy and joyful */
+
+    if ((bind(temp_socket,
+	      local_res_temp->ai_addr, 
+	      local_res_temp->ai_addrlen) != SOCKET_ERROR) &&
+	(listen(temp_socket,128) != SOCKET_ERROR))  {
+
+      /* OK, now add to the list */
+      temp_elt = (struct listen_elt *)malloc(sizeof(struct listen_elt));
+      if (temp_elt) {
+	temp_elt->fd = temp_socket;
+	if (listen_list) {
+	  temp_elt->next = listen_list;
+	}
+	else {
+	  listen_list = temp_elt;
+	  temp_elt->next = NULL;
+	}
+      }
+      else {
+	fprintf(stderr,
+		"%s: could not malloc a listen_elt\n",
+		__FUNCTION__);
+	fflush(stderr);
+	exit(1);
+      }
+	  
+      break;
+    }
+    else {
+      /* we consider a bind() or listen() failure a transient and try
+	 the next address */
+      if (debug) {
+	fprintf(stderr,
+		"%s: warning: bind or listen call failure: %s (errno %d)\n",
+		__FUNCTION__,
+		strerror(errno),
+		errno);
+	fflush(stderr);
+      }
+      local_res_temp = local_res_temp->ai_next;
+      continue;
+    }
+  }
+
+}
+
+void
+setup_listens(char name[], char port[], int af) {
+
+  int do_inet;
+  int no_name = 0;
+#ifdef AF_INET6
+  int do_inet6;
+#endif
+
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
+
+
+  if (strcmp(name,"") == 0) {
+    no_name = 1;
+    switch (af) {
+    case AF_UNSPEC:
+      do_inet = 1;
+#ifdef AF_INET6
+      do_inet6 = 1;
+#endif
+      break;
+    case AF_INET:
+      do_inet = 1;
+#ifdef AF_INET6
+      do_inet6 = 0;
+#endif
+      break;
+#ifdef AF_INET6
+    case AF_INET6:
+      do_inet = 0;
+      do_inet6 = 1;
+      break;
+#endif
+    default:
+      do_inet = 1;
+    }
+    /* if we have IPv6, try that one first because it may be a superset */
+#ifdef AF_INET6
+    if (do_inet6)
+      create_listens("::0",port,AF_INET6);
+#endif
+    if (do_inet)
+      create_listens("0.0.0.0",port,AF_INET);
+  }
+  else {
+    create_listens(name,port,af);
+  }
+
+  if (listen_list) {
+    fprintf(stdout,
+	    "Starting netserver with host '%s' port '%s' and family %s\n",
+	    (no_name) ? "IN(6)ADDR_ANY" : name,
+	    port,
+	    inet_ftos(af));
+    fflush(stdout);
+  }
+  else {
+    fprintf(stderr,
+	    "Unable to start netserver with  '%s' port '%s' and family %s\n",
+	    (no_name) ? "IN(6)ADDR_ANY" : name,
+	    port,
+	    inet_ftos(af));
+    fflush(stderr);
+    exit(1);
+  }
+}
+
+int
+set_fdset(struct listen_elt *list, fd_set *fdset) {
+
+  FD_ZERO(fdset);
+  struct listen_elt *temp;
+  int max = -1;
+
+  temp = list;
+
+  if (debug) {
+    fprintf(where,
+	    "%s: enter list %p fd_set %p\n",
+	    __FUNCTION__,
+	    list,
+	    fdset);
+    fflush(where);
+  }
+
+  while (temp) {
+    if (temp->fd > max)
+      max = temp->fd;
+
+    if (debug) {
+      fprintf(where,
+	      "setting %d in fdset\n",
+	      temp->fd);
+      fflush(where);
+    }
+
+    FD_SET(temp->fd,fdset);
+
+    temp = temp->next;
+  }
+
+  return max;
+
+}
+
+void
+close_listens(struct listen_elt *list) {
+  struct listen_elt *temp;
+
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
+
+  temp = list;
+  
+  while (temp) {
+    close(temp->fd);
+    temp = temp->next;
+  }
+}
+
 /* This routine implements the "main event loop" of the netperf server
    code. Code above it will have set-up the control connection so it
    can just merrily go about its business, which is to "schedule"
@@ -200,22 +612,32 @@
   
   float	temp_rate;
   
-  if (debug)    open_debug_file();
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
 
-
   while (1) {
-    recv_request();
 
+    if (recv_request() == 0) 
+      return;
+
     switch (netperf_request.content.request_type) {
       
     case DEBUG_ON:
       netperf_response.content.response_type = DEBUG_OK;
-      /*  dump_request already present in recv_request; redundant? */
-      if (!debug) {
-	debug++;
-	open_debug_file();
+      debug++;
+
+      if (debug == 1) {
+	/* we just flipped-on debugging, dump the request because
+	   recv_request/recv_request_n will not have dumped it as its
+	   dump_request() call is conditional on debug being set. raj
+	   2011-07-08 */
 	dump_request();
       }
+
       send_response();
       break;
       
@@ -224,32 +646,10 @@
 	debug--;
       netperf_response.content.response_type = DEBUG_OK;
       send_response();
-      /* +SAF why??? */
-      if (!debug) 
-      {
-	fclose(where);
-#if !defined(WIN32) && !defined(MPE) && !defined(__VMS) && !defined(MSDOS)
-	/* 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 !MSDOS */
-      }
+      /* we used to take the trouble to close the debug file, but SAF
+	 asked a good question when he asked "Why?" and since I cannot
+	 think of a good reason, I have removed the code. raj
+	 2011-07-08 */
       break;
 
     case DO_SYSINFO:
@@ -307,12 +707,13 @@
 	    (char *)netperf_response.content.test_specific_data,
 	    sizeof(temp_rate));
       bcopy((char *)&lib_num_loc_cpus,
-	    (char *)netperf_response.content.test_specific_data + sizeof(temp_rate),
+	    (char *)netperf_response.content.test_specific_data + 
+	            sizeof(temp_rate),
 	    sizeof(lib_num_loc_cpus));
       if (debug) {
 	fprintf(where,
-		"netserver: sending CPU information: rate is %g num cpu %d\n"
-		,temp_rate,
+		"netserver: sending CPU information: rate is %g num cpu %d\n",
+		temp_rate,
 		lib_num_loc_cpus);
 	fflush(where);
       }
@@ -477,417 +878,302 @@
   }
 }
 
-/*	
- set_up_server()
+/* the routine we call when we are going to spawn/fork/whatnot a child
+   process from the parent netserver daemon. raj 2011-07-08 */
+void
+spawn_child() {
 
- set-up the server listen socket. we only call this routine if the
- user has specified a port number on the command line or we believe we
- are not a child of inetd or its platform-specific equivalent */
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
 
-/*KC*/
+#if defined(HAVE_FORK)
+  FILE *rd_null_fp;    /* Used to redirect from "/dev/null". */
 
-void 
-set_up_server(char hostname[], char port[], int af)
-{ 
+  /* flush the usual suspects */
+  fflush(stdin);
+  fflush(stdout);
+  fflush(stderr);
+  fflush(where);
 
-  struct addrinfo     hints;
-  struct addrinfo     *local_res;
-  struct addrinfo     *local_res_temp;
+  switch (fork()) {
+  case -1:
+    fprintf(where,
+	    "%s: fork() error %s (errno %d)\n",
+	    __FUNCTION__,
+	    strerror(errno),
+	    errno);
+    fflush(where);
+    exit(1);
 
-  struct sockaddr_storage     peeraddr;
-  netperf_socklen_t                 peeraddr_len = sizeof(peeraddr);
-  
-  SOCKET server_control;
-  int on=1;
-  int count;
-  int error;
-  int not_listening;
+  case 0:
+    /* we are the child, but not of inetd.  we don't know if we are
+       the child of a daemonized parent or not, so we still need to
+       worry about the standard file descriptors. raj 2011-07-11 */
 
-#if !defined(WIN32) && !defined(MPE) && !defined(__VMS) && !defined(MSDOS)
-  FILE *rd_null_fp;    /* Used to redirect from "/dev/null". */
-  FILE *wr_null_fp;    /* Used to redirect to   "/dev/null". */
-#endif /* !WIN32 !MPE !__VMS !MDOS */
+    close_listens(listen_list);
+    open_debug_file();
 
-  if (debug) {
-    fprintf(stderr,
-            "set_up_server called with host '%s' port '%s' remfam %d\n",
-            hostname,
-	    port,
-            af);
-    fflush(stderr);
+    child = 1;
+    netperf_daemon = 0;
+    process_requests();
+    exit(0);
+    break;
+
+  default:
+    /* we are the parent, not a great deal to do here, but we may
+       want to reap some children */
+#if !defined(HAVE_SETSID)
+    /* Only call "waitpid()" if "setsid()" is not used. */
+    while(waitpid(-1, NULL, WNOHANG) > 0) { }
+#endif
+    break;
   }
 
-  memset(&hints,0,sizeof(hints));
-  hints.ai_family = af;
-  hints.ai_socktype = SOCK_STREAM;
-  hints.ai_protocol = IPPROTO_TCP;
-  hints.ai_flags = AI_PASSIVE;
+#elif defined(WIN32)
 
-  count = 0;
-  do {
-    error = getaddrinfo((char *)hostname,
-                        (char *)port,
-                        &hints,
-                        &local_res);
-    count += 1;
-    if (error == EAI_AGAIN) {
-      if (debug) {
-        fprintf(stderr,"Sleeping on getaddrinfo EAI_AGAIN\n");
-        fflush(stderr);
-      }
-      sleep(1);
+  BOOL b;
+  char *cmdline;
+  int cmdline_length;
+  int cmd_index;
+  PROCESS_INFORMATION pi;
+  STARTUPINFO si;
+  int i;
+	    
+  /* create the cmdline array based on strlen(program) + 80 chars */
+  cmdline_length = strlen(program) + 80;
+  cmdline = malloc(cmdline_length + 1);  // +1 for trailing null
+	    
+  memset(&si, 0 , sizeof(STARTUPINFO));
+  si.cb = sizeof(STARTUPINFO);
+	    
+  /* Pass the server_sock as stdin for the new process.  Hopefully
+     this will continue to be created with the OBJ_INHERIT
+     attribute. */
+  si.hStdInput = (HANDLE)server_sock;
+  si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+  si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+  si.dwFlags = STARTF_USESTDHANDLES;
+	    
+  /* Build cmdline for child process */
+  strcpy(cmdline, program);
+  cmd_index = strlen(cmdline);
+  if (verbosity > 1) {
+    cmd_index += snprintf(&cmdline[cmd_index],
+			  cmdline_length - cmd_index,
+			  " -v %d",
+			  verbosity);
+  }
+  for (i=0; i < debug; i++) {
+    cmd_index += snprintf(&cmdline[cmd_index],
+			  cmdline_length - cmd_index,
+			  " -d");
+  }
+  cmd_index += snprintf(&cmdline[cmd_index],
+			cmdline_length - cmd_index,
+			" -I %x",
+			(int)(UINT_PTR)server_sock);
+
+  /* are these -i settings even necessary? the command line scanning
+     does not seem to do anything with them */
+  cmd_index += snprintf(&cmdline[cmd_index],
+			cmdline_length - cmd_index,
+			" -i %x",
+			(int)(UINT_PTR)server_control);
+  cmd_index += snprintf(&cmdline[cmd_index],
+			cmdline_length - cmd_index,
+			" -i %x",
+			(int)(UINT_PTR)where);
+	    
+  b = CreateProcess(NULL,    /* Application Name */
+		    cmdline,
+		    NULL,    /* Process security attributes */
+		    NULL,    /* Thread security attributes */
+		    TRUE,    /* Inherit handles */
+		    0,       /* Creation flags
+				PROCESS_QUERY_INFORMATION,  */
+		    NULL,    /* Enviornment */
+		    NULL,    /* Current directory */
+		    &si,     /* StartupInfo */
+		    &pi);
+  if (!b)
+    {
+      perror("CreateProcessfailure: ");
+      free(cmdline); /* even though we exit :) */
+      exit(1);
     }
-  } while ((error == EAI_AGAIN) && (count <= 5));
+	    
+  /* We don't need the thread or process handles any more;
+     let them go away on their own timeframe. */
+	    
+  CloseHandle(pi.hThread);
+  CloseHandle(pi.hProcess);
+	    
+  /* the caller/parent will close server_sock */
 
-  if (error) {
-    fprintf(stderr,
-	    "set_up_server: could not resolve remote '%s' port '%s' af %d"
-	    "\n\tgetaddrinfo returned %d %s\n",
-	    hostname,
-	    port,
-	    af,
-	    error,
-	    gai_strerror(error));
-    exit(-1);
-  }
+  free(cmdline);
 
-  if (debug) {
-    dump_addrinfo(stderr, local_res, hostname, port, af);
-  }
+#else
 
-  not_listening = 1;
-  local_res_temp = local_res;
+  fprintf(where,
+	  "%s called on platform which cannot spawn children\n",
+	  __FUNCTION__);
+  fflush(where);
+  exit(1);
 
-  while((local_res_temp != NULL) && (not_listening)) {
+#endif /* HAVE_FORK */
+}
 
-    fprintf(stderr,
-	    "Starting netserver at port %s\n",
-	    port);
+void
+accept_connection(SOCKET listen_fd) {
 
-    server_control = socket(local_res_temp->ai_family,SOCK_STREAM,0);
+  struct sockaddr_storage peeraddr;
+  netperf_socklen_t peeraddrlen;
+#if defined(SO_KEEPALIVE)
+  int on = 1;
+#endif
 
-    if (server_control == INVALID_SOCKET) {
-      perror("set_up_server could not allocate a socket");
-      exit(-1);
-    }
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
 
-    /* happiness and joy, keep going */
-    if (setsockopt(server_control, 
-		   SOL_SOCKET, 
-		   SO_REUSEADDR, 
-		   (char *)&on , 
-		   sizeof(on)) == SOCKET_ERROR) {
-      if (debug) {
-	perror("warning: set_up_server could not set SO_REUSEADDR");
-      }
-    }
-    /* still happy and joyful */
+  peeraddrlen = sizeof(peeraddr);
 
-    if ((bind (server_control, 
-	       local_res_temp->ai_addr, 
-	       local_res_temp->ai_addrlen) != SOCKET_ERROR) &&
-	(listen (server_control,5) != SOCKET_ERROR))  {
-      not_listening = 0;
-      break;
-    }
-    else {
-      /* we consider a bind() or listen() failure a transient and try
-	 the next address */
-      if (debug) {
-	perror("warning: set_up_server failed a bind or listen call\n");
-      }
-      local_res_temp = local_res_temp->ai_next;
-      continue;
-    }
+  /* while server_control is only used by the WIN32 path, but why
+     bother ifdef'ing it?  and besides, do we *really* need knowledge
+     of server_control in the WIN32 case? do we have to tell the
+     child about *all* the listen endpoints? raj 2011-07-08 */
+  server_control = listen_fd;
+
+  if ((server_sock = accept(listen_fd,
+			   (struct sockaddr *)&peeraddr,
+			    &peeraddrlen)) == INVALID_SOCKET) {
+    fprintf(where,
+	    "%s: accept failure: %s (errno %d)\n",
+	    __FUNCTION__,
+	    strerror(errno),
+	    errno);
+    fflush(where);
+    exit(1);
   }
 
-  if (not_listening) {
-    fprintf(stderr,
-	    "set_up_server could not establish a listen endpoint for "
-	    "%s port %s with family %s\n",
-	    host_name,
-	    port,
-	    inet_ftos(af));
-    fflush(stderr);
-    exit(-1);
+#if defined(SO_KEEPALIVE)
+  /* we are not terribly concerned if this does not work, it is merely
+     duct tape added to belts and suspenders. raj 2011-07-08 */
+  setsockopt(server_sock,
+	     SOL_SOCKET,
+	     SO_KEEPALIVE,
+	     (const char *)&on,
+	     sizeof(on));
+#endif
+
+  if (spawn_on_accept) {
+    spawn_child();
+    /* spawn_child() only returns when we are the parent */
+    close(server_sock);
   }
   else {
-    printf("Starting netserver at hostname %s port %s and family %s\n",
-	   hostname,
-	   port,
-	   inet_ftos(af));
+    process_requests();
   }
+}
 
-  /*
-    setpgrp();
-    */
+void
+accept_connections() {
 
-#if !defined(WIN32) && !defined(MPE) && !defined(__VMS) && !defined(VMWARE_UW) && !defined(MSDOS)
-  /* Flush the standard I/O file descriptors before forking. */
-  fflush (stdin);
-  fflush (stdout);
-  fflush (stderr);
-#if defined(HAVE_FORK)
-  switch (fork())
-#else
-  switch (vfork())
-#endif
-    {
-    case -1:  	
-      perror("netperf server error");
-      exit(1);
-      
-    case 0:	
-      /* 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);
-      }
+  fd_set read_fds, write_fds, except_fds;
+  int high_fd, num_ready, candidate;
 
-      /* 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);
-      }
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
 
-      /* 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);
+  while (1) {
+
+    FD_ZERO(&write_fds);
+    FD_ZERO(&except_fds);
+    high_fd = set_fdset(listen_list,&read_fds);
+
+    num_ready = select(high_fd + 1,
+		       &read_fds,
+		       &write_fds,
+		       &except_fds,
+		       NULL);
+
+    /* try to keep things simple */
+    candidate = 0;
+    while ((num_ready) && (candidate <= high_fd)) {
+      if (FD_ISSET(candidate,&read_fds)) {
+	accept_connection(candidate);
       }
-      if (close (STDERR_FILENO) == -1)
-      {
-	perror ("netserver: closing stderr file descriptor");
-	exit   (1);
+      else {
+	candidate++;
       }
-      if (dup (fileno (wr_null_fp))  == -1)
-      {
-	perror ("netserver: dupicate /dev/null write file descr. to stderr");
-	exit   (1);
-      }
- 
-#ifndef NO_SETSID
-      setsid();
-#else
-      setpgrp();
-#endif /* NO_SETSID */
+    }
 
- /* some OS's have SIGCLD defined as SIGCHLD */
-#ifndef SIGCLD
-#define SIGCLD SIGCHLD
-#endif /* SIGCLD */
+    if (num_ready < 0) {
+      fprintf(where,
+	      "%s: select failure: %s (errno %d)\n",
+	      __FUNCTION__,
+	      strerror(errno),
+	      errno);
+      fflush(where);
+      exit(1);
+    }
+  }
+}
 
-      signal(SIGCLD, SIG_IGN);
-      
-#endif /* !WIN32 !MPE !__VMS !MSDOS */
-
-      for (;;)
-	{
-	  if ((server_sock=accept(server_control,
-				  (struct sockaddr *)&peeraddr,
-				  &peeraddr_len)) == INVALID_SOCKET)
-	    {
-	      printf("server_control: accept failed errno %d\n",errno);
-	      exit(1);
-	    }
-#if defined(MPE) || defined(__VMS) || defined(VMWARE_UW) || defined(MSDOS)
-	  /* Since we cannot fork this process , we cant fire any
-	     threads as they all share the same global data . So we
-	     better allow one request at at time */
-	  process_requests() ;
-#elif WIN32
-	  {
-	    BOOL b;
-	    char *cmdline;
-	    int cmdline_length;
-	    int cmd_index;
-	    PROCESS_INFORMATION pi;
-	    STARTUPINFO si;
-	    int i;
-	    
-	    /* create the cmdline array based on strlen(program) + 80 chars */
-	    cmdline_length = strlen(program) + 80;
-	    cmdline = malloc(cmdline_length + 1);  // +1 for trailing null
-	    
-	    memset(&si, 0 , sizeof(STARTUPINFO));
-	    si.cb = sizeof(STARTUPINFO);
-	    
-	    /* Pass the server_sock as stdin for the new process.
-	       Hopefully this will continue to be created with the
-	       OBJ_INHERIT attribute. */
-	    si.hStdInput = (HANDLE)server_sock;
-	    si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
-	    si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-	    si.dwFlags = STARTF_USESTDHANDLES;
-	    
-	    /* Build cmdline for child process */
-	    strcpy(cmdline, program);
-	    cmd_index = strlen(cmdline);
-	    if (verbosity > 1) {
-	      cmd_index += snprintf(&cmdline[cmd_index], cmdline_length - cmd_index, " -v %d", verbosity);
-	    }
-	    for (i=0; i < debug; i++) {
-	      cmd_index += snprintf(&cmdline[cmd_index], cmdline_length - cmd_index, " -d");
-	    }
-	    cmd_index += snprintf(&cmdline[cmd_index], cmdline_length - cmd_index, " -I %x", (int)(UINT_PTR)server_sock);
-	    cmd_index += snprintf(&cmdline[cmd_index], cmdline_length - cmd_index, " -i %x", (int)(UINT_PTR)server_control);
-	    cmd_index += snprintf(&cmdline[cmd_index], cmdline_length - cmd_index, " -i %x", (int)(UINT_PTR)where);
-	    
-	    b = CreateProcess(NULL,    /* Application Name */
-			      cmdline,
-			      NULL,    /* Process security attributes */
-			      NULL,    /* Thread security attributes */
-			      TRUE,    /* Inherit handles */
-			      0,       /* Creation flags
-					  PROCESS_QUERY_INFORMATION,  */
-			      NULL,    /* Enviornment */
-			      NULL,    /* Current directory */
-			      &si,     /* StartupInfo */
-			      &pi);
-	    if (!b)
-	      {
-		perror("CreateProcessfailure: ");
-		free(cmdline); /* even though we exit :) */
-		exit(1);
-	      }
-	    
-	    /* We don't need the thread or process handles any more;
-	       let them go away on their own timeframe. */
-	    
-	    CloseHandle(pi.hThread);
-	    CloseHandle(pi.hProcess);
-	    
-	    /* And close the server_sock since the child will own it. */
-	    
-	    close(server_sock);
-	    free(cmdline);
-	  }
+#ifndef WIN32
+#define SERVER_ARGS "DdfhL:n:p:v:V46"
 #else
-      signal(SIGCLD, SIG_IGN);
-#if defined(HAVE_FORK)
-	  switch (fork())
-#else
-	  switch (vfork())
+#define SERVER_ARGS "DdfhL:n:p:v:V46I:i:"
 #endif
-	    {
-	    case -1:
-	      /* something went wrong */
-	      exit(1);
-	    case 0:
-	      /* we are the child process */
-	      close(server_control);
-	      process_requests();
-	      exit(0);
-	      break;
-	    default:
-	      /* we are the parent process */
-	      close(server_sock);
-	      /* we should try to "reap" some of our children. on some
-	       systems they are being left as defunct processes. we
-	       will call waitpid, looking for any child process, with
-	       the WNOHANG feature. when waitpid return a zero, 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;
-	    }
-#endif /* !WIN32 !MPE !__VMS !MSDOS */
-	} /*for*/
-#if !defined(WIN32) && !defined(MPE) && !defined(__VMS) && !defined(VMWARE_UW) && !defined(MSDOS)
-      break; /*case 0*/
-      
-    default: 
-      exit (0);
-      
-    }
-#endif /* !WIN32 !MPE !__VMS !MSDOS */
-}
+void
+scan_netserver_args(int argc, char *argv[]) {
 
-int _cdecl
-main(int argc, char *argv[])
-{
-
-  int	c;
-  int   not_inetd = 0;
-#ifdef WIN32
-  BOOL  child = FALSE;
-#endif
+  int c;
   char arg1[BUFSIZ], arg2[BUFSIZ];
-#ifndef PATH_MAX
-#define PATH_MAX MAX_PATH
-#endif
-  char FileName[PATH_MAX];   /* for opening the debug log file */
 
-  struct sockaddr name;
-  netperf_socklen_t namelen = sizeof(name);
-  
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
 
-#ifdef WIN32
-	WSADATA	wsa_data ;
-
-	/* Initialize the winsock lib ( version 2.2 ) */
-	if ( WSAStartup(MAKEWORD(2,2), &wsa_data) == SOCKET_ERROR ){
-	  printf("WSAStartup() failed : %lu\n", GetLastError()) ;
-	  return -1 ;
-	}
-#endif /* WIN32 */
-
-	/* Save away the program name */
-	program = (char *)malloc(strlen(argv[0]) + 1);
-	if (program == NULL) {
-	  printf("malloc for program name failed!\n");
-	  return -1 ;
-	}
-	strcpy(program, argv[0]);
-
-  netlib_init();
-  
-  /* Scan the command line to see if we are supposed to set-up our own
-     listen socket instead of relying on inetd. */
-
-  /* first set a copy of initial values */
-  strncpy(local_host_name,"0.0.0.0",sizeof(local_host_name));
-  local_address_family = AF_UNSPEC;
-  strncpy(listen_port,TEST_PORT,sizeof(listen_port));
-
-  while ((c = getopt(argc, argv, SERVER_ARGS)) != EOF) {
+  while ((c = getopt(argc, argv, SERVER_ARGS)) != EOF){
     switch (c) {
     case '?':
     case 'h':
       print_netserver_usage();
       exit(1);
     case 'd':
-      /* we want to set the debug file name sometime */
       debug++;
-#ifdef MSDOS
-       dbug_init();
+      break;
+    case 'D':
+      /* perhaps one of these days we'll take an argument */
+      want_daemonize = 0;
+      not_inetd = 1;
+      break;
+    case 'f':
+      spawn_on_accept = 0;
+      not_inetd = 1;
+      break;
+#ifdef WIN32
+    case 'I':
+      child = TRUE;
+      break;
+    case 'i':
+      break;
 #endif
-      break;
     case 'L':
       not_inetd = 1;
       break_args_explicit(optarg,arg1,arg2);
@@ -896,15 +1182,6 @@
       }
       if (arg2[0]) {
 	local_address_family = parse_address_family(arg2);
-	/* if only the address family was set, we may need to set the
-	   local_host_name accordingly. since our defaults are IPv4
-	   this should only be necessary if we have IPv6 support raj
-	   2005-02-07 */  
-#if defined (AF_INET6)
-	if (!arg1[0]) {
-	  strncpy(local_host_name,"::0",sizeof(local_host_name));
-	}
-#endif
       }
       break;
     case 'n':
@@ -912,7 +1189,7 @@
       if (shell_num_cpus > MAXCPUS) {
 	fprintf(stderr,
 		"netserver: This version can only support %d CPUs. Please"
-		"           increase MAXCPUS in netlib.h and recompile.\n",
+		"increase MAXCPUS in netlib.h and recompile.\n",
 		MAXCPUS);
 	fflush(stderr);
 	exit(1);
@@ -929,7 +1206,6 @@
     case '6':
 #if defined(AF_INET6)
       local_address_family = AF_INET6;
-      strncpy(local_host_name,"::0",sizeof(local_host_name));
 #else
       local_address_family = AF_UNSPEC;
 #endif
@@ -942,129 +1218,204 @@
       printf("Netperf version %s\n",NETPERF_VERSION);
       exit(0);
       break;
-#ifdef WIN32
-/*+*+SAF */
-	case 'I':
-		child = TRUE;
-		/* This is the handle we expect to inherit. */
-		/*+*+SAF server_sock = (HANDLE)atoi(optarg); */
-		break;
-	case 'i':
-		/* This is a handle we should NOT inherit. */
-		/*+*+SAF CloseHandle((HANDLE)atoi(optarg)); */
-		break;
-#endif
-
+      
     }
   }
+}
 
-  /* +*+SAF I need a better way to find inherited handles I should close! */
-  /* +*+SAF Use DuplicateHandle to force inheritable attribute (or reset it)? */
+void
+daemonize() {
+#if defined(HAVE_FORK)
 
-/*  unlink(DEBUG_LOG_FILE); */
+  FILE *rd_null_fp;    /* Used to redirect from "/dev/null". */
 
-  strcpy(FileName, DEBUG_LOG_FILE);
-    
-#ifndef WIN32
-  snprintf(&FileName[strlen(FileName)], sizeof(FileName) - strlen(FileName), "_%d", getpid());
-  if ((where = fopen(FileName, "w")) == NULL) {
-    perror("netserver: debug file");
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
+  }
+
+  /* flush the usual suspects */
+  fflush(stdin);
+  fflush(stdout);
+  fflush(stderr);
+
+  switch (fork()) {
+  case -1:
+    fprintf(stderr,
+	    "%s: fork() error %s (errno %d)\n",
+	    __FUNCTION__,
+	    strerror(errno),
+	    errno);
+    fflush(stderr);
     exit(1);
+  case 0:
+
+    /* perhaps belt and suspenders, but if we dump core, perhaps
+       better to do so here. we won't worry about the call being
+       successful though. raj 2011-07-08 */
+    chdir(DEBUG_LOG_FILE_DIR);
+
+    /* we are the child. we should get a new "where" to match our new
+       pid */
+
+    open_debug_file();
+
+#ifdef HAVE_SETSID
+      setsid();
+#else
+      setpgrp();
+#endif /* HAVE_SETSID */
+
+      /* some OS's have SIGCLD defined as SIGCHLD */
+#ifndef SIGCLD
+#define SIGCLD SIGCHLD
+#endif /* SIGCLD */
+      
+      signal(SIGCLD, SIG_IGN);
+
+      /* ok, we can start accepting control connections now */
+      accept_connections();
+      
+  default:
+    /* we are the parent, nothing to do but exit? */
+    exit(0);
   }
+
 #else
-  {
-    
-    if (child) {
-      snprintf(&FileName[strlen(FileName)], sizeof(FileName) - strlen(FileName), "_%x", getpid());
-    }
-    
-    /* Hopefully, by closing stdout & stderr, the subsequent
-       fopen calls will get mapped to the correct std handles. */
-    fclose(stdout);
-    
-    if ((where = fopen(FileName, "w")) == NULL) {
-      perror("netserver: fopen of debug file as new stdout failed!");
-      exit(1);
-    }
-    
-    fclose(stderr);
-    
-    if ((where = fopen(FileName, "w")) == NULL) {
-      fprintf(stdout, "fopen of debug file as new stderr failed!\n");
-      exit(1);
-    }
+  fprintf(where,
+	  "%s called on platform which cannot daemonize\n",
+	  __FUNCTION__);
+  fflush(where);
+  exit(1);
+#endif /* HAVE_FORK */
+}
+
+static void
+check_if_inetd() {
+
+  if (debug) {
+    fprintf(where,
+	    "%s: enter\n",
+	    __FUNCTION__);
+    fflush(where);
   }
+
+  if (not_inetd) {
+    return;
+  }
+  else {
+#if !defined(WIN32) && !defined(__VMS)
+    struct sockaddr_storage name;
+    netperf_socklen_t namelen;
+
+    namelen = sizeof(name);
+    if (getsockname(0,
+		    (struct sockaddr *)&name,
+		    &namelen) == SOCKET_ERROR)
+      not_inetd = 1;
 #endif
- 
-#ifndef WIN32 
-  chmod(DEBUG_LOG_FILE,0644);
-#endif
+  }
+}
+
+/* OK, so how does all this work you ask?  Well, we are in a maze of
+   twisty options, all different.  Netserver can be invoked as a child
+   of inetd or the VMS auxiliary server process, or a parent netserver
+   process. In those cases, we could/should follow the "child"
+   path. However, there are really two "child" paths through the
+   netserver code.
+
+   When this netserver is a child of a parent netserver in the
+   case of *nix, the child process will be created by a
+   spawn_child_process() in accept_connections() and will not hit the
+   "child" path here in main().
+
+   When this netserver is a child of a parent netserver in the case of
+   windows, the child process will have been spawned via a
+   Create_Process() call in spawn_child_process() in
+   accept_connections, but will flow through here again. We rely on
+   the scan_netserver_args() call to have noticed the magic option
+   that tells us we are a child process.
+
+   When this netserver is launched from the command line we will first
+   set-up the listen endpoint(s) for the controll connection.  At that
+   point we decide if we want to and can become our own daemon, or
+   stay attached to the "terminal."  When this happens under *nix, we
+   will again take a fork() path via daemonize() and will not come
+   back through main().  If we ever learn how to become our own daemon
+   under Windows, we will undoubtedly take a Create_Process() path
+   again and will come through main() once again - that is what the
+   "daemon" case here is all about.
+
+   It is hoped that this is all much clearer than the old spaghetti
+   code that netserver had become.  raj 2011-07-11 */
+
+
+int _cdecl
+main(int argc, char *argv[]) {
+
+#ifdef WIN32
+  WSADATA	wsa_data ;
   
-#if WIN32
-  if (child) {
-	  server_sock = (SOCKET)GetStdHandle(STD_INPUT_HANDLE);
+  /* Initialize the winsock lib do we still want version 2.2? */
+  if ( WSAStartup(MAKEWORD(2,2), &wsa_data) == SOCKET_ERROR ){
+    printf("WSAStartup() failed : %lu\n", GetLastError()) ;
+    return -1 ;
   }
-#endif
+#endif /* WIN32 */
 
-  /* if we are not a child of an inetd or the like, then we should
-     open a socket and hang listens off of it. otherwise, we should go
-     straight into processing requests. the do_listen() routine will
-     sit in an infinite loop accepting connections and forking child
-     processes. the child processes will call process_requests */
+  fprintf(stderr,"ASD Save program\n");
+  /* Save away the program name */
+  program = (char *)malloc(strlen(argv[0]) + 1);
+  if (program == NULL) {
+    printf("malloc for program name failed!\n");
+    return -1 ;
+  }
+  strcpy(program, argv[0]);
   
-  /* If fd 0 is not a socket then assume we're not being called from
-     inetd and start server socket on the default port.  this
-     enhancement comes from vwelch at ncsa.uiuc.edu (Von Welch) */
-  if (not_inetd) {
-    /* the user specified a port number on the command line */
-    set_up_server(local_host_name,listen_port,local_address_family);
+  init_netserver_globals();
+
+  netlib_init();
+  
+  strncpy(local_host_name,"",sizeof(local_host_name));
+  local_address_family = AF_UNSPEC;
+  strncpy(listen_port,TEST_PORT,sizeof(listen_port));
+	  
+  scan_netserver_args(argc, argv);
+
+  check_if_inetd();
+
+  if (child) {
+    /* we are the child of either an inetd or parent netserver via
+       spawning (Windows) rather than fork()ing. if we were fork()ed
+       we would not be coming through this way. set_server_sock() must
+       be called before open_debug_file() or there is a chance that
+       we'll toast the descriptor when we do not wish it. */
+    set_server_sock();
+    open_debug_file();
+    process_requests();
   }
-#ifdef WIN32
-  /* OK, with Win2003 WinNT's POSIX subsystem is gone, and hence so is
-     fork.  But hopefully the kernel support will continue to exist
-     for some time.  We are not counting on the address space
-     copy_on_write support, since it isn't exposed except through the
-     NT native APIs (which are not public).  We will try to use the
-     InheritHandles flag in CreateProcess though since this is public
-     and is used for more than just POSIX so hopefully it won't go
-     away. */
-  else if (TRUE) {
-    if (child) {
-      process_requests();
-    } else {
-      strncpy(listen_port,TEST_PORT,sizeof(listen_port));
-      set_up_server(local_host_name,listen_port,local_address_family);
-    }
+  else if (daemon_parent) {
+    /* we are the parent daemonized netserver
+       process. accept_connections() will decide if we want to spawn a
+       child process */
+    accept_connections();
   }
-#endif
-#if !defined(__VMS)
-  else if (getsockname(0, &name, &namelen) == SOCKET_ERROR) {
-    /* we may not be a child of inetd */
-    if (errno == ENOTSOCK) {
-      strncpy(listen_port,TEST_PORT,sizeof(listen_port));
-      set_up_server(local_host_name,listen_port,local_address_family);
+  else {
+    /* we are the top netserver process, so we have to create the
+       listen endpoint(s) and decide if we want to daemonize */
+    setup_listens(local_host_name,listen_port,local_address_family);
+    if (want_daemonize) {
+      daemonize();
     }
+    accept_connections();
   }
-#endif /* !defined(__VMS) */
-  else {
-    /* we are probably a child of inetd, or are being invoked via the
-       VMS auxilliarly server mechanism */
-#if !defined(__VMS)
-    server_sock = 0;
-#else
-    if ( (server_sock = socket(TCPIP$C_AUXS, SOCK_STREAM, 0)) == INVALID_SOCKET ) 
-    { 
-      perror("Failed to grab aux server socket" ); 
-      exit(1); 
-    } 
-  
-#endif /* !defined(__VMS) */
-    process_requests();
-  }
+
 #ifdef WIN32
-	/* Cleanup the winsock lib */
-	WSACleanup();
+  WSACleanup();
 #endif
 
-  return(0);
+  return 0;
+	  
 }

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netsh.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -245,7 +245,9 @@
 \n\
 Options:\n\
     -h                Display this text\n\
+    -D                Do not daemonize\n\
     -d                Increase debugging output\n\
+    -f                Do not spawn chilren for each test, run serially\n\
     -L name,family    Use name to pick listen address and family for family\n\
     -p portnum        Listen for connect requests on portnum.\n\
     -4                Do IPv4\n\

Modified: trunk/src/netsys_linux.c
===================================================================
--- trunk/src/netsys_linux.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/netsys_linux.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -39,11 +39,13 @@
 	target[strlen(target)-1] = 0;
 	/* and four to go! */
 	*cpu_model = strdup(target+1);
+	fclose(proccpu);
 	return;
       }
     }
   } while (!feof(proccpu));
   *cpu_model = strdup("model_name");
+  fclose(proccpu);
 }
 
 static int
@@ -67,10 +69,12 @@
       if (strstr(linebuf,"cpu MHz") != NULL) {
 	target = strtok(linebuf,":");
 	target = strtok(NULL,":");
+	fclose(proccpu);
 	return rint(strtod(target+1,NULL));
       }
     }
   } while (!feof(proccpu));
+  fclose(proccpu);
   return -1;
 }
 

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2011-07-07 23:57:54 UTC (rev 421)
+++ trunk/src/nettest_omni.c	2011-07-11 21:58:41 UTC (rev 422)
@@ -6551,9 +6551,10 @@
 
   /* The current iteration loop now exits due to timeout or unit count
      being  reached */
-  
+  stop_timer();
   cpu_stop(omni_request->flags & OMNI_MEASURE_CPU,&elapsed_time);
-  
+  close(s_listen);
+
   if (timed_out) {
     /* we ended the test by time, which may have been PAD_TIME seconds
        longer than we wanted to run. so, we want to subtract pad_time



More information about the netperf-dev mailing list