Index: Makefile.in =================================================================== RCS file: /home/bright/cvs/webstone/src/Makefile.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile.in 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ Makefile.in 22 Dec 2003 14:55:03 -0000 1.2 @@ -64,9 +64,9 @@ .SUFFIXES: .SUFFIXES: .c .o -all: $(TARGETS) cgi api +all: $(TARGETS) cgi -install: all install-api install-cgi +install: all install-cgi $(CP) $(TARGETS) $(BINDIR) pure: all Index: acconfig.h =================================================================== RCS file: /home/bright/cvs/webstone/src/acconfig.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- acconfig.h 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ acconfig.h 22 Dec 2003 14:55:03 -0000 1.2 @@ -32,4 +32,10 @@ /* Should we use timezone in gettimeofday? */ #undef USE_TIMEZONE +/* Do we have realtime semaphores? */ +#undef HAVE_SEMAPHORES + +/* Do we want to be able to use ssh or rsh instead of rexec? */ +#undef USE_RCMDSH + /* end */ Index: bench.h =================================================================== RCS file: /home/bright/cvs/webstone/src/bench.h,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- bench.h 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ bench.h 22 Dec 2003 18:02:03 -0000 1.3 @@ -368,4 +368,39 @@ extern SOCKET connectsock(char *host, NETPORT portnum, char *protocol); +#ifdef UNIX_THREADS + +#define getitfunc(var) ((tls_getcb())->td_ ## var) + +#define debugfile getitfunc(debugfile) +#define logfile getitfunc(logfile) +#define timestat getitfunc(timestat) +#define timerarray getitfunc(timerarray) +#define mastersock getitfunc(mastersock) +#define page_stats getitfunc(page_stats) +struct thread_data { + FILE *td_debugfile; + FILE *td_logfile; + stats_t td_timestat; + rqst_timer_t td_timerarray[MAXNUMOFFILES]; + SOCKET td_mastersock; /* connection to webmaster */ + page_stats_t *td_page_stats; /* actually a dynamic array */ +}; + +struct thread_data *tls_getcb(void); + +#include +#include + +int InterlockedIncrement(int *val); +int _beginthread(void (*start_routine)(void *), int stack_size, void *arg); +void ReleaseSemaphore(sem_t *sem, int count, int *prev); +void CloseHandle(sem_t *sem); +void WaitForSingleObject(sem_t *sem, int time); + +#define GetLastError() errno + +#define INFINITE (-1) +#endif + #endif /* !__BENCH_H__ */ Index: config.h.in =================================================================== RCS file: /home/bright/cvs/webstone/src/config.h.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- config.h.in 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ config.h.in 22 Dec 2003 14:55:03 -0000 1.2 @@ -19,9 +19,6 @@ /* Define if you have the vprintf function. */ #undef HAVE_VPRINTF -/* Define if you have the waitpid system call. */ -#undef HAVE_WAITPID - /* Define if you have the wait3 system call. */ #undef HAVE_WAIT3 @@ -49,6 +46,12 @@ /* Should we use timezone in gettimeofday? */ #undef USE_TIMEZONE +/* Do we have realtime semaphores? */ +#undef HAVE_SEMAPHORES + +/* Do we want to be able to use ssh or rsh instead of rexec? */ +#undef USE_RCMDSH + /* Define if you have the gethostname function. */ #undef HAVE_GETHOSTNAME @@ -67,6 +70,9 @@ /* Define if you have the strncasecmp function. */ #undef HAVE_STRNCASECMP +/* Define if you have the waitpid function. */ +#undef HAVE_WAITPID + /* Define if you have the header file. */ #undef HAVE_FCNTL_H @@ -88,8 +94,19 @@ /* Define if you have the m library (-lm). */ #undef HAVE_LIBM +/* Define if you have the nsl library (-lnsl). */ +#undef HAVE_LIBNSL + /* Define if you have the socket library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define if you have the ucb library (-lucb). */ #undef HAVE_LIBUCB + +/* Define to the necessary symbol if this constant + uses a non-standard name on your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* Define if you have POSIX threads libraries and header files. */ +#undef HAVE_PTHREAD + Index: configure =================================================================== RCS file: /home/bright/cvs/webstone/src/configure,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ configure 22 Dec 2003 14:55:03 -0000 1.2 @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12.1 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -29,6 +29,7 @@ program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -143,6 +144,7 @@ --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -313,6 +315,11 @@ -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -334,7 +341,7 @@ verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12.1" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -478,12 +485,16 @@ srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" +if test -z "$sitefile"; then + if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi fi +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -504,9 +515,11 @@ # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -583,7 +596,7 @@ fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:587: checking host system type" >&5 +echo "configure:600: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -604,7 +617,7 @@ echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:608: checking target system type" >&5 +echo "configure:621: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -622,7 +635,7 @@ echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:626: checking build system type" >&5 +echo "configure:639: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -651,15 +664,16 @@ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:655: checking for $ac_word" >&5 +echo "configure:668: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -680,16 +694,17 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:684: checking for $ac_word" >&5 +echo "configure:698: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - for ac_dir in $PATH; do + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -724,25 +739,61 @@ echo "$ac_t""no" 1>&6 fi + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:749: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:732: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:781: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext < conftest.$ac_ext << EOF + +#line 792 "configure" #include "confdefs.h" + main(){return(0);} EOF -if { (eval echo configure:746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -756,18 +807,24 @@ ac_cv_prog_cc_works=no fi rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:766: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:823: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:771: checking whether we are using GNU C" >&5 +echo "configure:828: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -776,7 +833,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:780: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:837: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -787,11 +844,15 @@ if test $ac_cv_prog_gcc = yes; then GCC=yes - ac_test_CFLAGS="${CFLAGS+set}" - ac_save_CFLAGS="$CFLAGS" - CFLAGS= - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:795: checking whether ${CC-cc} accepts -g" >&5 +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:856: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -806,20 +867,24 @@ fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 - if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" - elif test $ac_cv_prog_cc_g = yes; then +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then CFLAGS="-g -O2" else - CFLAGS="-O2" + CFLAGS="-g" fi else - GCC= - test "${CFLAGS+set}" = set || CFLAGS="-g" + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:823: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:888: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -850,15 +915,16 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:854: checking for $ac_word" >&5 +echo "configure:919: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_AWK="$ac_prog" @@ -884,7 +950,7 @@ # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:888: checking for $ac_word" >&5 +echo "configure:954: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -896,8 +962,9 @@ ac_cv_path_PERL="$PERL" # Let the user override the test with a dos path. ;; *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in $PATH; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_path_PERL="$ac_dir/$ac_word" @@ -932,12 +999,12 @@ for ac_func in waitpid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:936: checking for $ac_func" >&5 +echo "configure:1003: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -988,7 +1055,7 @@ if test "${ac_cv_func_waitpid}" != 'yes' then echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6 -echo "configure:992: checking for wait3 that fills in rusage" >&5 +echo "configure:1059: checking for wait3 that fills in rusage" >&5 if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -996,7 +1063,7 @@ ac_cv_func_wait3_rusage=no else cat > conftest.$ac_ext < #include @@ -1027,7 +1094,7 @@ } } EOF -if { (eval echo configure:1031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_wait3_rusage=yes else @@ -1050,7 +1117,7 @@ fi echo $ac_n "checking for wait3 in -lucb""... $ac_c" 1>&6 -echo "configure:1054: checking for wait3 in -lucb" >&5 +echo "configure:1121: checking for wait3 in -lucb" >&5 ac_lib_var=`echo ucb'_'wait3 | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1058,7 +1125,7 @@ ac_save_LIBS="$LIBS" LIBS="-lucb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1103,7 +1170,7 @@ # # Replace `main' with a function in -lm: echo $ac_n "checking for floor in -lm""... $ac_c" 1>&6 -echo "configure:1107: checking for floor in -lm" >&5 +echo "configure:1174: checking for floor in -lm" >&5 ac_lib_var=`echo m'_'floor | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1111,7 +1178,7 @@ ac_save_LIBS="$LIBS" LIBS="-lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1150,7 +1217,7 @@ fi echo $ac_n "checking for rexec in -lcompat""... $ac_c" 1>&6 -echo "configure:1154: checking for rexec in -lcompat" >&5 +echo "configure:1221: checking for rexec in -lcompat" >&5 ac_lib_var=`echo compat'_'rexec | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1158,7 +1225,7 @@ ac_save_LIBS="$LIBS" LIBS="-lcompat $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1197,7 +1264,7 @@ fi echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:1201: checking for gethostbyname in -lnsl" >&5 +echo "configure:1268: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1205,7 +1272,7 @@ ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1244,7 +1311,7 @@ fi echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:1248: checking for connect in -lsocket" >&5 +echo "configure:1315: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1252,7 +1319,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsocket -lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1295,7 +1362,7 @@ # checks for header files # echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1299: checking how to run the C preprocessor" >&5 +echo "configure:1366: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1310,14 +1377,14 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1320: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1387: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -1327,14 +1394,31 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1337: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else @@ -1347,6 +1431,8 @@ rm -f conftest* fi rm -f conftest* +fi +rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" @@ -1356,12 +1442,12 @@ echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1360: checking for ANSI C header files" >&5 +echo "configure:1446: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1369,8 +1455,8 @@ #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1373: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1459: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes @@ -1386,7 +1472,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1404,7 +1490,7 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1425,7 +1511,7 @@ : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1436,7 +1522,7 @@ exit (0); } EOF -if { (eval echo configure:1440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1460,12 +1546,12 @@ fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:1464: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:1550: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1481,7 +1567,7 @@ s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:1485: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -1505,18 +1591,18 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1509: checking for $ac_hdr" >&5 +echo "configure:1595: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1519: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` +{ (eval echo configure:1605: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" @@ -1542,16 +1628,346 @@ done + + + + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + echo $ac_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS""... $ac_c" 1>&6 +echo "configure:1658: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + acx_pthread_ok=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + echo "$ac_t""$acx_pthread_ok" 1>&6 + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# pthread: Linux, etcetera +# --thread-safe: KAI C++ + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthread or + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" + ;; + *freebsd*) + + # Try for userland threads first on FreeBSD, they work well + # with network IO. + + acx_pthread_flags="-pthread -lthr -lkse pthread -mt $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + echo $ac_n "checking whether pthreads work without any flags""... $ac_c" 1>&6 +echo "configure:1745: checking whether pthreads work without any flags" >&5 + ;; + + -*) + echo $ac_n "checking whether pthreads work with $flag""... $ac_c" 1>&6 +echo "configure:1750: checking whether pthreads work with $flag" >&5 + PTHREAD_CFLAGS="$flag" + ;; + + *) + echo $ac_n "checking for the pthreads library -l$flag""... $ac_c" 1>&6 +echo "configure:1756: checking for the pthreads library -l$flag" >&5 + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + cat > conftest.$ac_ext < +int main() { +pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); +; return 0; } +EOF +if { (eval echo configure:1785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + acx_pthread_ok=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + echo "$ac_t""$acx_pthread_ok" 1>&6 + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: threads are created detached by default + # and the JOINABLE attribute has a nonstandard name (UNDETACHED). + echo $ac_n "checking for joinable pthread attribute""... $ac_c" 1>&6 +echo "configure:1817: checking for joinable pthread attribute" >&5 + cat > conftest.$ac_ext < +int main() { +int attr=PTHREAD_CREATE_JOINABLE; +; return 0; } +EOF +if { (eval echo configure:1826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ok=PTHREAD_CREATE_JOINABLE +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ok=unknown +fi +rm -f conftest* + if test x"$ok" = xunknown; then + cat > conftest.$ac_ext < +int main() { +int attr=PTHREAD_CREATE_UNDETACHED; +; return 0; } +EOF +if { (eval echo configure:1845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ok=PTHREAD_CREATE_UNDETACHED +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ok=unknown +fi +rm -f conftest* + fi + if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then + cat >> confdefs.h <<\EOF +#define PTHREAD_CREATE_JOINABLE $ok +EOF + + fi + echo "$ac_t""${ok}" 1>&6 + if test x"$ok" = xunknown; then + echo "configure: warning: we do not know how to create joinable pthreads" 1>&2 + fi + + echo $ac_n "checking if more special flags are required for pthreads""... $ac_c" 1>&6 +echo "configure:1868: checking if more special flags are required for pthreads" >&5 + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + echo "$ac_t""${flag}" 1>&6 + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with cc_r + # Extract the first word of "cc_r", so it can be a program name with args. +set dummy cc_r; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1886: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_PTHREAD_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$PTHREAD_CC"; then + ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_PTHREAD_CC="cc_r" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_PTHREAD_CC" && ac_cv_prog_PTHREAD_CC="${CC}" +fi +fi +PTHREAD_CC="$ac_cv_prog_PTHREAD_CC" +if test -n "$PTHREAD_CC"; then + echo "$ac_t""$PTHREAD_CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + PTHREAD_CC="$CC" +fi + + + + + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + cat >> confdefs.h <<\EOF +#define HAVE_PTHREAD 1 +EOF + + : +else + acx_pthread_ok=no + +fi +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + + + +cat > conftest.$ac_ext < +int main() { +sem_t sem;sem_init(&sem, 0, 1);sem_post(&sem);sem_wait(&sem); +; return 0; } +EOF +if { (eval echo configure:1949: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + cat >> confdefs.h <<\EOF +#define HAVE_SEMAPHORES 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + + # # checks for typedefs, structures, and compiler characteristics # echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1550: checking for working const" >&5 +echo "configure:1966: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2020: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1621,12 +2037,12 @@ fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1625: checking for size_t" >&5 +echo "configure:2041: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1635,7 +2051,7 @@ #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_size_t=yes else @@ -1654,12 +2070,12 @@ fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1658: checking return type of signal handlers" >&5 +echo "configure:2074: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1676,7 +2092,7 @@ int i; ; return 0; } EOF -if { (eval echo configure:1680: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1695,12 +2111,12 @@ echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1699: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:2115: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1709,7 +2125,7 @@ struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1713: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2129: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -1730,12 +2146,12 @@ fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:1734: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:2150: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1743,7 +2159,7 @@ struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:1747: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -1764,12 +2180,12 @@ fi echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6 -echo "configure:1768: checking for tm_zone in struct tm" >&5 +echo "configure:2184: checking for tm_zone in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -1777,7 +2193,7 @@ struct tm tm; tm.tm_zone; ; return 0; } EOF -if { (eval echo configure:1781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2197: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_zone=yes else @@ -1797,12 +2213,12 @@ else echo $ac_n "checking for tzname""... $ac_c" 1>&6 -echo "configure:1801: checking for tzname" >&5 +echo "configure:2217: checking for tzname" >&5 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef tzname /* For SGI. */ @@ -1812,7 +2228,7 @@ atoi(*tzname); ; return 0; } EOF -if { (eval echo configure:1816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_tzname=yes else @@ -1834,7 +2250,7 @@ fi cat > conftest.$ac_ext < int main() { @@ -1842,7 +2258,7 @@ gettimeofday(&thetime, &thezone); ; return 0; } EOF -if { (eval echo configure:1846: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2262: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define USE_TIMEZONE 1 @@ -1858,7 +2274,7 @@ # checks for library functions # echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 -echo "configure:1862: checking for 8-bit clean memcmp" >&5 +echo "configure:2278: checking for 8-bit clean memcmp" >&5 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1866,7 +2282,7 @@ ac_cv_func_memcmp_clean=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_memcmp_clean=yes else @@ -1891,15 +2307,15 @@ fi echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 -test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o" +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:1898: checking for vprintf" >&5 +echo "configure:2314: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -1946,12 +2362,12 @@ if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:1950: checking for _doprnt" >&5 +echo "configure:2366: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -2001,12 +2417,12 @@ for ac_func in gethostname gettimeofday select socket strerror strncasecmp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2005: checking for $ac_func" >&5 +echo "configure:2421: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2079,6 +2495,26 @@ +echo $ac_n "checking If we'll honor the environment varialbe WEBSTONE_RSH""... $ac_c" 1>&6 +echo "configure:2500: checking If we'll honor the environment varialbe WEBSTONE_RSH" >&5 +flag=no +case "$host_os" in +*freebsd* | *linux*) +flag="yes" +;; +esac +echo "$ac_t""${flag}" 1>&6 +if test "x$flag" != xno; then + cat >> confdefs.h <<\EOF +#define USE_RCMDSH 1 +EOF + +fi + +LIBS="$PTHREAD_LIBS $LIBS" +CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +CC="$PTHREAD_CC" + # # all done # @@ -2105,7 +2541,7 @@ # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1 | grep ac_space` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -2172,7 +2608,7 @@ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12.1" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -2195,6 +2631,7 @@ s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -2236,6 +2673,9 @@ s%@PERL@%$PERL%g s%@PERL_SCRIPTS@%$PERL_SCRIPTS%g s%@CPP@%$CPP%g +s%@PTHREAD_CC@%$PTHREAD_CC%g +s%@PTHREAD_LIBS@%$PTHREAD_LIBS%g +s%@PTHREAD_CFLAGS@%$PTHREAD_CFLAGS%g s%@LIBOBJS@%$LIBOBJS%g s%@NSAPICFLAGS@%$NSAPICFLAGS%g s%@LD_SHAREDCMD@%$LD_SHAREDCMD%g Index: configure.in =================================================================== RCS file: /home/bright/cvs/webstone/src/configure.in,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- configure.in 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ configure.in 22 Dec 2003 14:55:03 -0000 1.2 @@ -86,6 +86,209 @@ AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h limits.h sgtty.h sys/time.h unistd.h) +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# pthread: Linux, etcetera +# --thread-safe: KAI C++ + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthread or + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" + ;; + *freebsd*) + + # Try for userland threads first on FreeBSD, they work well + # with network IO. + + acx_pthread_flags="-pthread -lthr -lkse pthread -mt $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: threads are created detached by default + # and the JOINABLE attribute has a nonstandard name (UNDETACHED). + AC_MSG_CHECKING([for joinable pthread attribute]) + AC_TRY_LINK([#include ], + [int attr=PTHREAD_CREATE_JOINABLE;], + ok=PTHREAD_CREATE_JOINABLE, ok=unknown) + if test x"$ok" = xunknown; then + AC_TRY_LINK([#include ], + [int attr=PTHREAD_CREATE_UNDETACHED;], + ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) + fi + if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then + AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, + [Define to the necessary symbol if this constant + uses a non-standard name on your system.]) + fi + AC_MSG_RESULT(${ok}) + if test x"$ok" = xunknown; then + AC_MSG_WARN([we do not know how to create joinable pthreads]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix*) flag="-D_THREAD_SAFE";; + *-freebsd*) flag="-D_THREAD_SAFE -D_REENTRANT";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with cc_r + AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) +else + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD + +ACX_PTHREAD() + +AC_TRY_COMPILE([#include ], + [sem_t sem;sem_init(&sem, 0, 1);sem_post(&sem);sem_wait(&sem); ], + AC_DEFINE(HAVE_SEMAPHORES), ) + + # # checks for typedefs, structures, and compiler characteristics # @@ -130,6 +333,22 @@ esac AC_SUBST(NSAPICFLAGS) AC_SUBST(LD_SHAREDCMD) + +AC_MSG_CHECKING([If we'll honor the environment varialbe WEBSTONE_RSH]) +flag=no +case "$host_os" in +*freebsd* | *linux*) +flag="yes" +;; +esac +AC_MSG_RESULT(${flag}) +if test "x$flag" != xno; then + AC_DEFINE(USE_RCMDSH) +fi + +LIBS="$PTHREAD_LIBS $LIBS" +CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +CC="$PTHREAD_CC" # # all done Index: genrand.c =================================================================== RCS file: /home/bright/cvs/webstone/src/genrand.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- genrand.c 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ genrand.c 22 Dec 2003 14:55:03 -0000 1.2 @@ -31,7 +31,7 @@ #include #include "sysdep.h" -void +int main(const int argc, char* argv[]) { FILE* file; Index: sysdep.c =================================================================== RCS file: /home/bright/cvs/webstone/src/sysdep.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- sysdep.c 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ sysdep.c 22 Dec 2003 14:55:03 -0000 1.2 @@ -24,6 +24,120 @@ #include "sysdep.h" +#include "bench.h" + +#ifdef UNIX_THREADS + +#include +#include +#include + +pthread_once_t tls_once = PTHREAD_ONCE_INIT; +pthread_key_t tls_key; + +static void tls_key_init(void); + +/* Initialize the per-thread key. */ +static void +tls_key_init(void) +{ + + if (pthread_key_create(&tls_key, NULL) != 0) + exit(1); +} + +/* Return per-thread instance data. */ +struct thread_data * +tls_getcb(void) +{ + struct thread_data *tdp; + + if (pthread_once(&tls_once, tls_key_init) != 0) + exit(1); + + tdp = pthread_getspecific(tls_key); + if (tdp == NULL) { + tdp = calloc(1, sizeof(*tdp)); + if (tdp == NULL) + errexit("failed to alloc thread data, aborting\n"); + if (pthread_setspecific(tls_key, tdp) != 0) + errexit("failed to set thread data, aborting\n"); + tdp->td_mastersock = BADSOCKET_VALUE; + tdp->td_debugfile = stderr; + } + return (tdp); +} + + +int +InterlockedIncrement(int *val) +{ + static pthread_mutex_t interlock_mtx = PTHREAD_MUTEX_INITIALIZER; + int rv; + + pthread_mutex_lock(&interlock_mtx); + rv = *val; + (*val)++; + pthread_mutex_unlock(&interlock_mtx); + return (rv); +} + +int +_beginthread(void (*start_routine)(void *), int stack_size, void *arg) +{ + pthread_t dummy; + pthread_attr_t attr; + int err; + + err = pthread_attr_init(&attr); + if (err) + goto errout; + err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if (err) + goto errout; + if (stack_size != 0 && + (err = pthread_attr_setstacksize(&attr, stack_size)) != 0) + goto errout; + + err = pthread_create(&dummy, &attr, + (void *(*)(void *))start_routine, arg); + if (err) + goto errout; + pthread_attr_destroy(&attr); + return (0); +errout: + errno = err; + return (-1); +} + +void +ReleaseSemaphore(sem_t *sem, int count, int *prev) +{ + + if (prev != NULL) + sem_getvalue(sem, prev); + while (count--) + sem_post(sem); +} + +void +CloseHandle(sem_t *sem) +{ + + sem_destroy(sem); +} + +void +WaitForSingleObject(sem_t *sem, int time) +{ + + if (time != INFINITE) + errexit("WaitForSingleObject called with time set\n"); + sem_wait(sem); +} + +#endif + /* strerror() */ #ifndef HAVE_STRERROR /* strerror is not available on SunOS 4.1.3 and others */ Index: sysdep.h =================================================================== RCS file: /home/bright/cvs/webstone/src/sysdep.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- sysdep.h 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ sysdep.h 22 Dec 2003 14:55:03 -0000 1.2 @@ -40,6 +40,10 @@ #include #endif /* WIN32 */ +#if !defined(WIN32) && defined(HAVE_PTHREAD) && defined(HAVE_SEMAPHORES) +#define UNIX_THREADS +#endif + /* MAXHOSTNAMELEN is undefined on some systems */ #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 Index: webclient.c =================================================================== RCS file: /home/bright/cvs/webstone/src/webclient.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- webclient.c 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ webclient.c 22 Dec 2003 18:02:03 -0000 1.3 @@ -22,6 +22,7 @@ * @(#) bench.c 2.4@(#) * ***************************************************************************/ +#define UNIX_THREADS #include #include @@ -58,6 +59,7 @@ #include "bench.h" #define _BSD_SIGNALS +#undef INFINITY #define INFINITY 100000000 #define DEFAULTWWWPORT 80 #define LOG_FILE "logfile" @@ -79,14 +81,16 @@ char proxyserver[MAXHOSTNAMELEN]; char debug_filename[MAXPATHLEN]; -THREAD FILE *debugfile = stderr; +#ifndef UNIX_THREADS +THREAD FILE *debugfile; THREAD FILE *logfile; THREAD stats_t timestat; THREAD rqst_timer_t timerarray[MAXNUMOFFILES]; THREAD SOCKET mastersock = BADSOCKET_VALUE; /* connection to webmaster */ +THREAD page_stats_t *page_stats; /* actually a dynamic array */ +#endif /* UNIX_THREADS */ page_list_t *load_file_list; /* actually a dynamic array */ -THREAD page_stats_t *page_stats; /* actually a dynamic array */ long int numfiles = 0; long int numargs = 0; @@ -106,6 +110,10 @@ #ifdef WIN32 HANDLE hSemaphore; int CounterSemaphore = 0; /* counter semaphore for children */ +#elif defined (UNIX_THREADS) +sem_t hSem; +sem_t *hSemaphore = &hSem; +int CounterSemaphore = 0; /* counter semaphore for children */ #endif /* WIN32 */ static void ClientThread(void *); @@ -118,7 +126,6 @@ /* End of globals */ - static void usage(const char *progname) { @@ -147,7 +154,7 @@ timeexpired = 1; } -#ifndef WIN32 +#if !defined(WIN32) && !defined(UNIX_THREADS) static void childhandler(int sig) { @@ -169,7 +176,7 @@ #endif ; /* do nothing */ } -#endif /* WIN32 */ +#endif /* WIN32 | UNIX_THREADS */ /* look up the host name and protocol @@ -379,7 +386,7 @@ static void -accumstats(rqst_timer_t *rqsttimer, page_stats_t *pagestats, stats_t *timestat) +accumstats(rqst_timer_t *rqsttimer, page_stats_t *pagestats, stats_t *tstat) { rqst_stats_t rqststats; @@ -412,9 +419,9 @@ * Update statistics. */ rqstat_times(&(rqststats), rqsttimer); - rqstat_sum(&(timestat->rs), &(rqststats)); + rqstat_sum(&(tstat->rs), &(rqststats)); rqstat_sum(&(pagestats->rs), &(rqststats)); - timestat->page_numbers[rqsttimer->page_number]++; + tstat->page_numbers[rqsttimer->page_number]++; } @@ -691,7 +698,7 @@ } } -void +int main(int argc, char *argv[]) { long fcount = 0; @@ -700,9 +707,7 @@ int err; FILE *fp; -#ifndef WIN32 - debugfile = stderr; -#else +#ifdef WIN32 WSADATA WSAData; MessageBeep(~0U); /* announce our existence */ @@ -723,7 +728,12 @@ hSemaphore = CreateSemaphore(NULL, 0, 1, NULL); if(hSemaphore == NULL) errexit("Create semaphore failed: %d", GetLastError()); -#endif /* WIN32 */ +#elif defined(UNIX_THREADS) + if (sem_init(hSemaphore, 0, 0) == -1) + errexit("Create semaphore failed: %s", strerror(errno)); +#else + debugfile = stderr; +#endif memset(webserver, 0, sizeof(webserver)); memset(webmaster, 0, sizeof(webmaster)); @@ -832,7 +842,7 @@ fflush(stdout); } -#ifndef WIN32 +#if !defined(WIN32) && !defined(UNIX_THREADS) /* * If we are to fork additional clients on this machine, * we must do it before we connect to the master. @@ -882,8 +892,8 @@ if ((pid == -1) && errno == ECHILD) break; } -#else /* defined(WIN32) */ - /* start threads on NT */ +#else /* defined(WIN32) | defined(UNIX_THREADS) */ + /* start threads */ for (i = 0; i < numclients; i++) { if (_beginthread(ClientThread, 0, (void *) random_seed) == -1) @@ -928,7 +938,7 @@ CloseHandle(hSemaphore); #endif /* WIN32 */ - return; + return 0; } void @@ -1018,7 +1028,7 @@ errexit("Error connecting to the master: %s\n", neterrstr()); } -#ifdef WIN32 +#if defined(WIN32) || defined(UNIX_THREADS) /* Tell parent we're ready */ InterlockedIncrement(&CounterSemaphore); @@ -1281,8 +1291,11 @@ fclose(debugfile); } -#ifdef WIN32 +#if defined(WIN32) || defined(UNIX_THREADS) /* tell parent we're done */ InterlockedIncrement(&CounterSemaphore); #endif /* WIN32 */ +#if defined(UNIX_THREADS) + pthread_detach(pthread_self()); +#endif } Index: webmaster.c =================================================================== RCS file: /home/bright/cvs/webstone/src/webmaster.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- webmaster.c 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ webmaster.c 22 Dec 2003 14:55:03 -0000 1.2 @@ -52,6 +52,8 @@ #include "sysdep.h" #include "bench.h" +#undef page_stats + /* command line options/data */ int savefile = 0; int debug = DEBUG_OFF; @@ -88,7 +90,9 @@ SOCKET socknum[MAXCLIENTS]; SOCKET sockIO[MAXTOTALPROCS]; SOCKET sockErr[MAXTOTALPROCS]; -THREAD FILE *debugfile = stderr; +#ifndef UNIX_THREADS +THREAD FILE *debugfile; +#endif struct hostent *master_phe; /* IP addresses for webmaster */ @@ -697,6 +701,98 @@ strcpy(commandline,tmpcommandline); } +#ifdef USE_RCMDSH + +/* a replacement for rexec using popen, we can't do the signal thingy */ +int +my_rexec(char **ahost, u_short port, char *user, char *pass, char *cmd, int *fd2p) +{ + char *prog; + int retfd, fd2; + pid_t pid; + int iofds[2], errfds[2]; +#define MAX_ARGS 255 + char **ap, *argv[MAX_ARGS], *inputstring; + + iofds[0] = iofds[1] = errfds[0] = errfds[1] = -1; + + prog = getenv("WEBSTONE_RSH"); + D_PRINTF("my_rexec %s %s\n\n\n", + prog == NULL ? "calling rexec" : "running", + prog == NULL ? "" : prog); + + if (prog == NULL) + return (rexec(ahost, port, user, pass, cmd, fd2p)); + + if (pipe(iofds) == -1) { + perror("pipe"); + goto err; + } + + if (fd2p != NULL && pipe(errfds) == -1) { + perror("pipe"); + goto err; + } + + pid = fork(); + if (pid == -1) { + perror("fork"); + goto err; + } + + /* parent */ + if (pid != 0) { + if (fd2p != NULL) { + *fd2p = errfds[0]; + close(errfds[1]); + } + close(iofds[1]); + return (iofds[0]); + } + + ap = argv; + *ap++ = prog; + *ap++ = "-l"; + *ap++ = user; + *ap++ = *ahost; + inputstring = cmd; + for (; (*ap = strsep(&inputstring, " \t")) != NULL;) { + if (**ap != '\0') { + if (++ap >= &argv[MAX_ARGS]) { + exit(EXIT_FAILURE); + break; + } + } + } + + close(iofds[0]); + if (dup2(iofds[1], STDOUT_FILENO) == -1 || + dup2(iofds[1], STDIN_FILENO) == -1) + exit(EXIT_FAILURE); + + if (fd2p != NULL) { + close(errfds[0]); + fd2 = errfds[1]; + } else { + fd2 = iofds[1]; + } + if (dup2(fd2, STDERR_FILENO) == -1) + exit(EXIT_FAILURE); + + if (execvp(prog, argv) == -1) { + exit(EXIT_FAILURE); + } + +err: + close(iofds[0]); + close(iofds[1]); + close(errfds[0]); + close(errfds[1]); + return (-1); +} +#define rexec(ahost, port, username, passwd, command, fd2p) \ + my_rexec(ahost, port, username, passwd, command, fd2p) +#endif /* * rexec to the client hosts and start the webclients @@ -1343,7 +1439,7 @@ } #endif /* WIN32 */ -void +int main(const int argc, char *argv[]) { @@ -1385,6 +1481,7 @@ /* Initalization of variables. */ /* debugfile = stdout; */ + debugfile = stderr; memset(buffer, 0, NCCARGS); memset(webserver, 0, MAXHOSTNAMELEN); memset(configfile, 0, MAXPATHLEN); Index: CGI-test/ws25_cgi.c =================================================================== RCS file: /home/bright/cvs/webstone/src/CGI-test/ws25_cgi.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- CGI-test/ws25_cgi.c 22 Dec 2003 09:44:26 -0000 1.1.1.1 +++ CGI-test/ws25_cgi.c 22 Dec 2003 14:55:03 -0000 1.2 @@ -62,7 +62,7 @@ #include #include -void +int main() { char *query_string;