[netperf-dev] netperf4 commit notice r72 - in trunk: . src

raj at netperf.org raj at netperf.org
Thu Mar 2 15:26:32 PST 2006


Author: raj
Date: 2006-03-02 15:26:26 -0800 (Thu, 02 Mar 2006)
New Revision: 72

Modified:
   trunk/configure
   trunk/configure.ac
   trunk/src/netlib.c
   trunk/src/netlib.h
   trunk/src/netlib_linux.c
   trunk/src/netmsg.c
   trunk/src/netperf.c
   trunk/src/netperf.h
   trunk/src/netserver.c
Log:
More big steps towards glib.  It helps to actually properly initialize
the mutexes and condition variables of the test_set_hash...


Modified: trunk/configure
===================================================================
--- trunk/configure	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/configure	2006-03-02 23:26:26 UTC (rev 72)
@@ -20546,7 +20546,8 @@
 	;;
 esac
 
-# Checks for libraries.
+# Checks for libraries.  the check for pthread has been moved to where
+# we decide if we are using glib or not.
 
 echo "$as_me:$LINENO: checking for main in -lm" >&5
 echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6
@@ -20616,74 +20617,6 @@
 ac_cv_lib_m=ac_cv_lib_m_main
 
 
-echo "$as_me:$LINENO: checking for main in -lpthread" >&5
-echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6
-if test "${ac_cv_lib_pthread_main+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthread  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-
-int
-main ()
-{
-main ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_pthread_main=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_pthread_main=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5
-echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6
-if test $ac_cv_lib_pthread_main = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPTHREAD 1
-_ACEOF
-
-  LIBS="-lpthread $LIBS"
-
-fi
-ac_cv_lib_pthread=ac_cv_lib_pthread_main
-
-
 echo "$as_me:$LINENO: checking for main in -ldl" >&5
 echo $ECHO_N "checking for main in -ldl... $ECHO_C" >&6
 if test "${ac_cv_lib_dl_main+set}" = set; then
@@ -20752,7 +20685,8 @@
 ac_cv_lib_dl=ac_cv_lib_dl_main
 
 
-# Checks for header files.
+# Checks for header files. the check for pthread.h has been move to
+# where we decide if we are using glib or not
 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
 if test "${ac_cv_header_stdc+set}" = set; then
@@ -21025,8 +20959,7 @@
 
 
 
-
-for ac_header in arpa/inet.h arpa/nameser.h arpa/nameser_compat.h dlfcn.h errno.h fcntl.h float.h inttypes.h limits.h malloc.h math.h memory.h netdb.h netinet/in.h netinet/tcp.h poll.h pthread.h pwd.h resolv.h sched.h signal.h stdint.h stdio.h stdlib.h string.h strings.h sys/dk.h sys/ioctl.h sys/param.h sys/pstat.h sys/resource.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/uio.h unistd.h values.h
+for ac_header in arpa/inet.h arpa/nameser.h arpa/nameser_compat.h dlfcn.h errno.h fcntl.h float.h inttypes.h limits.h malloc.h math.h memory.h netdb.h netinet/in.h netinet/tcp.h poll.h pwd.h resolv.h sched.h signal.h stdint.h stdio.h stdlib.h string.h strings.h sys/dk.h sys/ioctl.h sys/param.h sys/pstat.h sys/resource.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/uio.h unistd.h values.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -24106,13 +24039,232 @@
 #define WITH_GLIB 1
 _ACEOF
 
-else
+   else
 	{ { echo "$as_me:$LINENO: error: Cannot find pkg-config and so cannot use glib." >&5
 echo "$as_me: error: Cannot find pkg-config and so cannot use glib." >&2;}
    { (exit 1); exit 1; }; }
+   fi
+else
+# this is going to be pthreads
+
+echo "$as_me:$LINENO: checking for main in -lpthread" >&5
+echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6
+if test "${ac_cv_lib_pthread_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_pthread_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_pthread_main=no
 fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5
+echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6
+if test $ac_cv_lib_pthread_main = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
 
+  LIBS="-lpthread $LIBS"
+
+fi
+ac_cv_lib_pthread=ac_cv_lib_pthread_main
+
+
+for ac_header in pthread.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to the netperf lists.  ##
+## ---------------------------------- ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+fi
+
 # see if we should be enabling histogram support
 
 echo "$as_me:$LINENO: checking whether to include histogram support" >&5

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/configure.ac	2006-03-02 23:26:26 UTC (rev 72)
@@ -37,15 +37,16 @@
 	;;
 esac
 
-# Checks for libraries.
+# Checks for libraries.  the check for pthread has been moved to where
+# we decide if we are using glib or not.
 AC_HAVE_LIBRARY(m)
-AC_HAVE_LIBRARY(pthread)
 AC_HAVE_LIBRARY(dl)
 
-# Checks for header files.
+# Checks for header files. the check for pthread.h has been move to
+# where we decide if we are using glib or not
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h arpa/nameser.h arpa/nameser_compat.h dlfcn.h errno.h fcntl.h float.h inttypes.h limits.h malloc.h math.h memory.h netdb.h netinet/in.h netinet/tcp.h poll.h pthread.h pwd.h resolv.h sched.h signal.h stdint.h stdio.h stdlib.h string.h strings.h sys/dk.h sys/ioctl.h sys/param.h sys/pstat.h sys/resource.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/uio.h unistd.h values.h ])
+AC_CHECK_HEADERS([arpa/inet.h arpa/nameser.h arpa/nameser_compat.h dlfcn.h errno.h fcntl.h float.h inttypes.h limits.h malloc.h math.h memory.h netdb.h netinet/in.h netinet/tcp.h poll.h pwd.h resolv.h sched.h signal.h stdint.h stdio.h stdlib.h string.h strings.h sys/dk.h sys/ioctl.h sys/param.h sys/pstat.h sys/resource.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/uio.h unistd.h values.h ])
 
 # Some platforms require these.  There may be a better way.
 AC_HAVE_LIBRARY(socket)
@@ -134,10 +135,14 @@
 	glib_cflags=`pkg-config --cflags glib-2.0`
 	glib_libs=`pkg-config --libs glib-2.0`
 	AC_DEFINE([WITH_GLIB],1,[Define to one to use glib instead of direct pthreads])
+   else
+	AC_MSG_ERROR(Cannot find pkg-config and so cannot use glib.)
+   fi
 else
-	AC_MSG_ERROR(Cannot find pkg-config and so cannot use glib.)
+# this is going to be pthreads
+  AC_HAVE_LIBRARY(pthread)
+  AC_CHECK_HEADERS([pthread.h])
 fi
-fi
 
 # see if we should be enabling histogram support
 

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netlib.c	2006-03-02 23:26:26 UTC (rev 72)
@@ -91,18 +91,22 @@
 #include <sys/resource.h>
 #endif
 
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
-
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
 
-#if HAVE_GLIB_H
-#include <glib.h>
-#endif 
+#ifdef WITH_GLIB
+# ifdef HAVE_GLIB_H
+#  include <glib.h>
+# endif 
+#else
+# ifdef HAVE_PTHREAD_H
+#  include <pthread.h>
+# endif
+#endif
 
+
+
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -401,12 +405,8 @@
           "srvr","tst","test_name","CURR","TEST","RQST");
   for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
     h = &test_hash[i];
-    ret = NETPERF_MUTEX_LOCK(&h->hash_lock);
-    if (ret) {
-      fprintf(where,"%s thread mutex lock returned %d\n",__func__,ret);
-      fflush(where);
-    }
-    test = h->test;
+    NETPERF_MUTEX_LOCK(h->hash_lock);
+        test = h->test;
 
     while (test != NULL) {
       if (!xmlStrcmp(test->server_id,server->id)) {
@@ -414,11 +414,7 @@
       }
       test = test->next;
     }
-    ret = NETPERF_MUTEX_UNLOCK(&h->hash_lock);
-    if (ret) {
-      fprintf(where,"%s thread mutex unlock returned %d\n",__func__,ret);
-      fflush(where);
-    }
+    NETPERF_MUTEX_UNLOCK(h->hash_lock);
   }
 }
 
@@ -613,12 +609,12 @@
   hash_value = TEST_HASH_VALUE(new_test->id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_hash[hash_value].hash_lock);
 
   new_test->next = test_hash[hash_value].test;
   test_hash[hash_value].test = new_test;
 
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
 
   return(NPE_SUCCESS);
 }
@@ -639,7 +635,7 @@
   hash_value = TEST_HASH_VALUE(id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_hash[hash_value].hash_lock);
 
   prev_test    = &(test_hash[hash_value].test);
   test_pointer = test_hash[hash_value].test;
@@ -654,7 +650,7 @@
     test_pointer = test_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
 }
 
 test_t *
@@ -670,7 +666,7 @@
   hash_value = TEST_HASH_VALUE(id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_hash[hash_value].hash_lock);
 
   test_pointer = test_hash[hash_value].test;
   while (test_pointer != NULL) {
@@ -681,7 +677,7 @@
     test_pointer = test_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
   return(test_pointer);
 }
 
@@ -1081,8 +1077,16 @@
 }
 
 
+/* I would have used the NETPERF_THREAD_T abstraction, but that would
+   make netlib.h dependent on netperf.h and I'm not sure I want to do
+   that. raj 2006-03-02 */
 int
-launch_thread(NETPERF_THREAD_T *tid, void *(*start_routine)(void *), void *data)
+#ifdef WITH_GLIB
+launch_thread(GThread *tid, void *(*start_routine)(void *), void *data)
+#else
+launch_thread(pthread_t *tid, void *(*start_routine)(void *), void *data)
+#endif
+
 {
   int rc;
 

Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netlib.h	2006-03-02 23:26:26 UTC (rev 72)
@@ -96,7 +96,11 @@
 				xmlChar *nid, const xmlChar *fromnid);
 extern int32_t recv_control_message(int control_sock, xmlDocPtr *message);
 extern void report_server_error(server_t *server);
+#ifdef WITH_GLIB
+extern int launch_thread(GThread *tid, void *(*start_routine)(void *), void *data);
+#else
 extern int launch_thread(pthread_t *tid, void *(*start_routine)(void *), void *data);
+#endif
 extern int set_thread_locality(test_t *test, char *loc_type, char *loc_value);
 extern void break_args_explicit(char *s, char *arg1, char *arg2);
 extern int parse_address_family(char family_string[]);
@@ -120,7 +124,7 @@
   unsigned int valid_states;
 };
 
-void netlib_init();
+extern void netlib_init();
 
 void display_test_hash();
 #endif

Modified: trunk/src/netlib_linux.c
===================================================================
--- trunk/src/netlib_linux.c	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netlib_linux.c	2006-03-02 23:26:26 UTC (rev 72)
@@ -83,17 +83,17 @@
      grins. raj 2006-01-24 */
 
   if (strcmp(loc_type,"PROC") == 0) {
-    err  = sched_setaffinity(test->tid,
+    err  = sched_setaffinity(test->thread_id,
 			     sizeof(mask),
 			     &mask);
   }
   else if (strcmp(loc_type,"LDOM") == 0) {
-    err  = sched_setaffinity(test->tid,
+    err  = sched_setaffinity(test->thread_id,
 			     sizeof(mask),
 			     &mask);
   }
   else if (strcmp(loc_type,"PSET") == 0) {
-    err  = sched_setaffinity(test->tid,
+    err  = sched_setaffinity(test->thread_id,
 			     sizeof(mask),
 			     &mask);
   }

Modified: trunk/src/netmsg.c
===================================================================
--- trunk/src/netmsg.c	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netmsg.c	2006-03-02 23:26:26 UTC (rev 72)
@@ -576,7 +576,7 @@
     fprintf(where,"np_idle_message: waiting for mutex\n");
     fflush(where);
   }
-  NETPERF_MUTEX_LOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_hash[hash_value].hash_lock);
 
   test = test_hash[hash_value].test;
   while (test != NULL) {
@@ -593,17 +593,23 @@
       fflush(where);
     }
     test->state = TEST_IDLE;
-    rc = NETPERF_COND_BROADCAST(test_hash[hash_value].condition);
+    /* I'd have liked to have abstracted this with the NETPERF_mumble
+       macros, but the return values differ. raj 2006-03-02 */
+#ifdef WITH_GLIB
+    g_cond_broadcast(test_hash[hash_value].condition);
+#else
+    rc = pthread_cond_broadcast(test_hash[hash_value].condition);
     if (debug) {
       fprintf(where," new_state = %d\n",test->state);
       fflush(where);
     }
+#endif
   }
   if (debug) {
     fprintf(where,"np_idle_message: unlocking mutex\n");
     fflush(where);
   }
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
   return(rc);
 }
 
@@ -724,7 +730,7 @@
   hash_value = TEST_HASH_VALUE(testid);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_hash[hash_value].hash_lock);
 
   test = test_hash[hash_value].test;
   while (test != NULL) {
@@ -751,14 +757,26 @@
     } else {
       test->state = TEST_INIT;
     }
+
+    /* since the different cond broadcast calls return different
+       things, we cannot use the nice NETPERF_mumble abstractions. */
+#ifdef WITH_GLIB
+
+    g_cond_broadcast(test_hash[hash_value].condition);
+
+#else
+
     rc = NETPERF_COND_BROADCAST(test_hash[hash_value].condition);
-      
+
+#endif      
+
     if (debug) {
       fprintf(where," new_state = %d rc = %d\n",test->state,rc);
       fflush(where);
     }
+
   }
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
   return(rc);
 }
 
@@ -921,16 +939,16 @@
     if (rc == NPE_SUCCESS) {
       if (debug) {
         fprintf(where,
-                "test_message: about to launch thread for test %d using func %p\n",
-                new_test->tid,
+                "test_message: about to launch thread %d for test using func %p\n",
+                new_test->thread_id,
                 new_test->test_func);
         fflush(where);
       }
-      rc = launch_thread(&new_test->tid,new_test->test_func,new_test);
+      rc = launch_thread(&new_test->thread_id,new_test->test_func,new_test);
       if (debug) {
         fprintf(where,
-                "test_message: launched thread for test %d\n",
-                new_test->tid);
+                "test_message: launched thread %d for test\n",
+                new_test->thread_id);
         fflush(where);
       }
     }
@@ -948,7 +966,7 @@
         if (debug) {
           fprintf(where,
                   "test_message: waiting on thread %d\n",
-                  new_test->tid);
+                  new_test->thread_id);
           fflush(where);
         }
         sleep(1);
@@ -956,7 +974,7 @@
       if (debug) {
         fprintf(where,
                 "test_message: test has finished initialization on thread %d\n",
-                new_test->tid);
+                new_test->thread_id);
         fflush(where);
       }
     }

Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netperf.c	2006-03-02 23:26:26 UTC (rev 72)
@@ -360,7 +360,13 @@
   for (i = 0; i < SERVER_HASH_BUCKETS; i++) {
     server_hash[i].server = NULL;
 #ifdef WITH_GLIB
-    server_hash[i].hash_lock = G_STATIC_MUTEX_INIT;
+    server_hash[i].hash_lock = g_mutex_new();
+    if (NULL == server_hash[i].hash_lock) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_cond_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
     server_hash[i].condition = g_cond_new();
     if (NULL == server_hash[i].condition) {
       /* not sure we will even get here */
@@ -369,7 +375,16 @@
       exit(-2);
     }
 #else
-    rc = pthread_mutex_init(&(server_hash[i].hash_lock), NULL);
+    server_hash[i].hash_lock = 
+      (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+
+    if (NULL == server_hash[i].hash_lock) {
+      fprintf(where, "%s: unable to malloc a mutex \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_mutex_init(server_hash[i].hash_lock, NULL);
     if (rc) {
       fprintf(where, "%s: pthread_mutex_init error %d\n",__func__,rc);
       fflush(where);
@@ -396,16 +411,31 @@
   for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
     test_hash[i].test = NULL;
 #ifdef WITH_GLIB
-    test_hash[i].hash_lock = G_STATIC_MUTEX_INIT;
+    test_hash[i].hash_lock = g_mutex_new();
+    if (NULL == test_hash[i].hash_lock) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_mutex_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
     test_hash[i].condition = g_cond_new();
     if (NULL == test_hash[i].condition) {
       /* not sure we will even get here */
-      fprintf(where, "netperf_init: g_cond_new error \n");
+      fprintf(where, "%s: g_cond_new error \n",__func__);
       fflush(where);
       exit(-2);
     }
 #else
-    rc = pthread_mutex_init(&(test_hash[i].hash_lock), NULL);
+    test_hash[i].hash_lock = 
+      (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+
+    if (NULL == test_hash[i].hash_lock) {
+      fprintf(where, "%s: unable to malloc a mutex \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_mutex_init(test_hash[i].hash_lock, NULL);
     if (rc) {
       fprintf(where, "netperf_init: pthread_mutex_init error %d\n",rc);
       fflush(where);
@@ -430,6 +460,61 @@
 #endif
   }
 
+  /* you know, it might not be a bad idea to also properly initialize
+     the test_set_hash stuff too, nudge nudge to you know who!  */
+
+  for (i = 0; i < TEST_SET_HASH_BUCKETS; i ++) {
+    test_set_hash[i].test_set = NULL;
+#ifdef WITH_GLIB
+    test_set_hash[i].hash_lock = g_mutex_new();
+    if (NULL == test_set_hash[i].hash_lock) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_mutex_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+    test_set_hash[i].condition = g_cond_new();
+    if (NULL == test_set_hash[i].condition) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_cond_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+#else
+    test_set_hash[i].hash_lock = 
+      (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+
+    if (NULL == test_set_hash[i].hash_lock) {
+      fprintf(where, "%s: unable to malloc a mutex \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_mutex_init(test_set_hash[i].hash_lock, NULL);
+    if (rc) {
+      fprintf(where, "netperf_init: pthread_mutex_init error %d\n",rc);
+      fflush(where);
+      exit(-2);
+    }
+
+    test_set_hash[i].condition = 
+      (pthread_cond_t *)malloc(sizeof(pthread_cond_t));
+
+    if (NULL == test_set_hash[i].condition) {
+      fprintf(where, "netperf_init: unable to malloc a pthread_cond_t \n");
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_cond_init((test_set_hash[i].condition), NULL);
+    if (rc) {
+      fprintf(where, "netperf_init: pthread_cond_init error %d\n",rc);
+      fflush(where);
+      exit(-2);
+    }
+#endif
+  }
+
   netlib_init();
 }
 
@@ -460,13 +545,13 @@
   hash_value = ((atoi((char *)new_server->id + 1)) % SERVER_HASH_BUCKETS);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(server_hash[hash_value].hash_lock);
 
   new_server->next = server_hash[hash_value].server;
-  new_server->lock = &(server_hash[hash_value].hash_lock);
+  new_server->lock = server_hash[hash_value].hash_lock;
   server_hash[hash_value].server = new_server;
 
-  NETPERF_MUTEX_UNLOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(server_hash[hash_value].hash_lock);
 
   return(NPE_SUCCESS);
 }
@@ -485,7 +570,7 @@
   hash_value = ((atoi((char *)id + 1)) % SERVER_HASH_BUCKETS);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(server_hash[hash_value].hash_lock);
 
   prev_server    = &(server_hash[hash_value].server);
   server_pointer = server_hash[hash_value].server;
@@ -500,7 +585,7 @@
     server_pointer = server_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(server_hash[hash_value].hash_lock);
 
 }
 
@@ -517,7 +602,7 @@
   hash_value = ((atoi((char *)id + 1)) % SERVER_HASH_BUCKETS);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(server_hash[hash_value].hash_lock);
 
   server_pointer = server_hash[hash_value].server;
   while (server_pointer != NULL) {
@@ -528,7 +613,7 @@
     server_pointer = server_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(server_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(server_hash[hash_value].hash_lock);
 
   return(server_pointer);
 }
@@ -542,13 +627,13 @@
   hash_value = TEST_SET_HASH_VALUE(new_test_set->id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_set_hash[hash_value].hash_lock);
 
   new_test_set->next = test_set_hash[hash_value].test_set;
 
   test_set_hash[hash_value].test_set = new_test_set;
 
-  NETPERF_MUTEX_UNLOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_set_hash[hash_value].hash_lock);
 
   return(NPE_SUCCESS);
 }
@@ -566,7 +651,7 @@
   hash_value = TEST_SET_HASH_VALUE(id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_set_hash[hash_value].hash_lock);
 
   test_set_ptr = test_set_hash[hash_value].test_set;
   while (test_set_ptr != NULL) {
@@ -586,7 +671,7 @@
     }
   }
 
-  NETPERF_MUTEX_UNLOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_set_hash[hash_value].hash_lock);
 
   return(NPE_SUCCESS);
 }
@@ -603,7 +688,7 @@
   hash_value = TEST_SET_HASH_VALUE(id);
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(test_set_hash[hash_value].hash_lock);
 
   test_set_ptr = test_set_hash[hash_value].test_set;
   while (test_set_ptr != NULL) {
@@ -614,7 +699,7 @@
     test_set_ptr = test_set_ptr->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(test_set_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_set_hash[hash_value].hash_lock);
   return(test_set_ptr);
 }
 
@@ -743,7 +828,7 @@
       if (add_server_to_hash(new_server) == NPE_SUCCESS) {
         new_server->node      = this_netserver;
 #ifdef WITH_GLIB
-	new_server->rwlock = G_STATIC_RW_LOCK_INIT;
+	g_static_rw_lock_init(&new_server->rwlock);
 #else
         rc = pthread_rwlock_init(&new_server->rwlock, NULL);
         if (rc) {
@@ -886,7 +971,7 @@
   /* find the dependency in the hash list */
   hash_value = TEST_HASH_VALUE(id);
   h = &(test_hash[hash_value]);
-  NETPERF_MUTEX_LOCK(&h->hash_lock);
+  NETPERF_MUTEX_LOCK(h->hash_lock);
   test = h->test;
   while (test != NULL) {
     if (!xmlStrcmp(test->id,id)) {
@@ -912,42 +997,44 @@
 #endif
       /* wait for test to initialize */
       while (test->state == TEST_PREINIT) {
-        NETPERF_MUTEX_UNLOCK(&h->hash_lock);
+        NETPERF_MUTEX_UNLOCK(h->hash_lock);
         if (debug) {
           fprintf(where,
                   "resolve_dependency: waiting on test %s thread %d\n",
                   (char *)id,
-                  test->tid);
+                  test->thread_id);
           fflush(where);
         }
 
-        NETPERF_MUTEX_LOCK(&h->hash_lock);
+        NETPERF_MUTEX_LOCK(h->hash_lock);
 
 #ifdef WITH_GLIB
+	g_cond_timedwait(h->condition, &h->hash_lock, &abstime);
 #else
         get_expiration_time(&delta_time,&abstime);
-#endif
 
-        rc = NETPERF_COND_TIMEDWAIT(h->condition, &h->hash_lock, &abstime);
+
+        rc = pthread_cond_timedwait(h->condition, h->hash_lock, &abstime);
         if (debug) {
             fprintf(where,
                     "resolve_dependency: pthread_cond_wait exited %d\n",rc);
             fflush(where);
         }
+#endif
       }  /* end wait */
       
       /* test has reached at least the TEST_INIT state */
       if (test->state != TEST_ERROR) {
         if (test->dependent_data != NULL) {
           *data = test->dependent_data;
-          NETPERF_MUTEX_UNLOCK(&h->hash_lock);
+          NETPERF_MUTEX_UNLOCK(h->hash_lock);
           rc = NPE_SUCCESS;
           if (debug) {
             fprintf(where,"resolve_dependency: successful for %s\n",
                     (char *)id);
             fflush(where);
           }
-          NETPERF_MUTEX_LOCK(&h->hash_lock);
+          NETPERF_MUTEX_LOCK(h->hash_lock);
         } else {
           rc = NPE_DEPENDENCY_NOT_PRESENT;
         }
@@ -959,7 +1046,7 @@
 
     test = test->next;
   }
-  NETPERF_MUTEX_UNLOCK(&(test_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(test_hash[hash_value].hash_lock);
   return(rc);
 }
 
@@ -1022,7 +1109,7 @@
                                 msg,
                                 server->id,
                                 my_nid);
-      NETPERF_RWLOCK_UNLOCK(&server->rwlock);
+      NETPERF_RWLOCK_WRITER_UNLOCK(&server->rwlock);
     } else {
       if (debug) {
         fprintf(where,
@@ -1064,16 +1151,16 @@
 
   for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
     h = &test_hash[i];
-    NETPERF_MUTEX_LOCK(&h->hash_lock);
+    NETPERF_MUTEX_LOCK(h->hash_lock);
     test = h->test;
     while (test != NULL) {
       if (test->state_req == TEST_PREINIT) {
         if (!xmlStrcmp(server->id, test->server_id)) {
           /* test is not initialized and belongs to this netserver init it */
           test->state_req = TEST_IDLE;
-          NETPERF_MUTEX_UNLOCK(&h->hash_lock);
-          rc = launch_thread(&test->tid, initialize_test, test);
-          NETPERF_MUTEX_LOCK(&h->hash_lock);
+          NETPERF_MUTEX_UNLOCK(h->hash_lock);
+          rc = launch_thread(&test->thread_id, initialize_test, test);
+          NETPERF_MUTEX_LOCK(h->hash_lock);
           if (rc != NPE_SUCCESS) {
             test->state = TEST_ERROR;
             test->err_rc = rc;
@@ -1089,7 +1176,7 @@
         test = test->next;
       }
     }
-    NETPERF_MUTEX_UNLOCK(&h->hash_lock);
+    NETPERF_MUTEX_UNLOCK(h->hash_lock);
   }
 
   NETPERF_DEBUG_EXIT(debug,where);
@@ -1167,12 +1254,12 @@
   }
   for (i = 0; i < SERVER_HASH_BUCKETS; i ++) {
     h = &server_hash[i];
-    NETPERF_MUTEX_LOCK(&h->hash_lock);
+    NETPERF_MUTEX_LOCK(h->hash_lock);
     server = h->server;
     while (server != NULL) {
       if (server->state_req == NSRV_INIT) {
         /* netserver worker thread needs to be started */
-        NETPERF_MUTEX_UNLOCK(&h->hash_lock);
+        NETPERF_MUTEX_UNLOCK(h->hash_lock);
         if (debug) {
           fprintf(where,"launching thread for netserver %s\n",server->id);
           fflush(where);
@@ -1184,7 +1271,7 @@
                   server->tid,server->id);
           fflush(where);
         }
-        NETPERF_MUTEX_LOCK(&h->hash_lock);
+        NETPERF_MUTEX_LOCK(h->hash_lock);
         if (rc != NPE_SUCCESS) {
           server->state = NSRV_ERROR;
           server->err_rc = rc;
@@ -1193,7 +1280,7 @@
       }
       server = server->next;
     }
-    NETPERF_MUTEX_UNLOCK(&h->hash_lock);
+    NETPERF_MUTEX_UNLOCK(h->hash_lock);
   }
 
   NETPERF_DEBUG_EXIT(debug,where);
@@ -1221,10 +1308,7 @@
   }
   for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
     h = &test_hash[i];
-#ifdef WITH_GLIB
-#else
-    NETPERF_MUTEX_LOCK(&h->hash_lock);
-#endif
+    NETPERF_MUTEX_LOCK(h->hash_lock);
     test = h->test;
     while (test != NULL) {
       while (test->state != TEST_IDLE) {
@@ -1240,16 +1324,17 @@
         }
         /* test is not yet initialized wait for it */
 #ifdef WITH_GLIB
+	g_cond_timedwait(h->condition, &h->hash_lock, &abstime);
 #else
         get_expiration_time(&delta_time,&abstime);
-#endif
-        prc = NETPERF_COND_TIMEDWAIT(h->condition, &h->hash_lock, &abstime);
+
+        prc = pthread_cond_timedwait(h->condition, h->hash_lock, &abstime);
         if (prc != 0) {
           fprintf(where,
             "wait_for_tests_to_initialize: thread conditional wait returned %d\n",prc);
           fflush(where);
         }
-
+#endif
         /* since the mutex was unlocked during the conditional wait
            should the hash chain be restarted in case a new test was
            inserted ? */
@@ -1257,10 +1342,7 @@
       } 
       test = test->next;
     }
-#ifdef WITH_GLIB
-#else
-    NETPERF_MUTEX_UNLOCK(&h->hash_lock);
-#endif
+    NETPERF_MUTEX_UNLOCK(h->hash_lock);
   }
   for (i=0;i < SERVER_HASH_BUCKETS; i++) {
     server = server_hash[i].server;

Modified: trunk/src/netperf.h
===================================================================
--- trunk/src/netperf.h	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netperf.h	2006-03-02 23:26:26 UTC (rev 72)
@@ -42,6 +42,18 @@
 
 #ifdef WITH_GLIB
 #include <glib.h>
+#define NETPERF_MUTEX_T GMutex
+#define NETPERF_RWLOCK_T GStaticRWLock
+#define NETPERF_THREAD_T GThread
+#define NETPERF_COND_T GCond
+#define NETPERF_ABS_TIMESPEC GTimeVal
+#define NETPERF_ABS_TIMESET(base,a,b) base.tv_sec = a;base.tv_usec=b;
+#define NETPERF_MUTEX_LOCK g_mutex_lock
+#define NETPERF_MUTEX_UNLOCK g_mutex_unlock
+#define NETPERF_COND_TIMEDWAIT g_cond_timedwait
+#define NETPERF_COND_BROADCAST g_cond_broadcast
+#define NETPERF_RWLOCK_WRLOCK g_static_rwlock_writer_lock
+#define NETPERF_RWLOCK_WRITER_UNLOCK g_static_rwlock_writer_unlock
 #elif defined(HAVE_PTHREAD_H)
 #include <pthread.h>
 #define NETPERF_MUTEX_T pthread_mutex_t
@@ -55,7 +67,7 @@
 #define NETPERF_COND_TIMEDWAIT pthread_cond_timedwait
 #define NETPERF_COND_BROADCAST pthread_cond_broadcast
 #define NETPERF_RWLOCK_WRLOCK pthread_rwlock_wrlock
-#define NETPERF_RWLOCK_UNLOCK pthread_rwlock_unlock
+#define NETPERF_RWLOCK_WRITER_UNLOCK pthread_rwlock_unlock
 #else
 #error Netperf4 requires either glib or pthreads
 #endif
@@ -200,7 +212,7 @@
 #define SERVER_HASH_BUCKETS 4
 
 typedef struct server_hash_elt {
-  NETPERF_MUTEX_T  hash_lock;
+  NETPERF_MUTEX_T  *hash_lock;
   NETPERF_COND_T   *condition;
   server_t        *server;
 } server_hash_t;
@@ -273,15 +285,11 @@
 
   int        err_no;           /* The errno returned by the failing syscall */
   
-  NETPERF_THREAD_T  tid;       /* the posix thread id of the test
-                                  instance within the netserver.
-                                  Will only be stored in the netserver
-                                  process(es) not the netperf
-                                  process. this stems from a pthread_t
-                                  being something that is supposed to
-                                  be opaque to the user, so there is
-                                  no way to know how to communicate it
-                                  to another process/host. */
+  NETPERF_THREAD_T thread_id;   /* as the different threads packages
+				   have differnt concepts of what the
+				   opaque thread id should be we will
+				   have to do some interesting
+				   backflips to deal with them */
 
   xmlChar   *test_name;        /* the ASCII name of the test being
                                   performed by this test instance. */
@@ -337,7 +345,7 @@
 
 
 typedef struct test_hash_elt {
-  NETPERF_MUTEX_T  hash_lock;
+  NETPERF_MUTEX_T  *hash_lock;
   NETPERF_COND_T   *condition;
   test_t          *test;
 } test_hash_t;
@@ -395,7 +403,7 @@
 
 
 typedef struct test_set_hash_elt {
-  NETPERF_MUTEX_T  hash_lock;
+  NETPERF_MUTEX_T  *hash_lock;
   NETPERF_COND_T   *condition;
   tset_t          *test_set;
 } tset_hash_t;

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2006-03-02 20:10:11 UTC (rev 71)
+++ trunk/src/netserver.c	2006-03-02 23:26:26 UTC (rev 72)
@@ -271,13 +271,13 @@
 
   hash_value = 0;
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(netperf_hash[hash_value].hash_lock);
 
   new_netperf->next = netperf_hash[hash_value].server;
-  new_netperf->lock = &(netperf_hash[hash_value].hash_lock);
+  new_netperf->lock = netperf_hash[hash_value].hash_lock;
   netperf_hash[hash_value].server = new_netperf;
 
-  NETPERF_MUTEX_UNLOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(netperf_hash[hash_value].hash_lock);
 
   return(NPE_SUCCESS);
 }
@@ -297,7 +297,7 @@
   hash_value = 0;
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(netperf_hash[hash_value].hash_lock);
 
   prev_server    = &(netperf_hash[hash_value].server);
   server_pointer = netperf_hash[hash_value].server;
@@ -312,7 +312,7 @@
     server_pointer = server_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(netperf_hash[hash_value].hash_lock);
 }
 
 
@@ -329,7 +329,7 @@
   hash_value = 0;
 
   /* don't forget to add error checking one day */
-  NETPERF_MUTEX_LOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_LOCK(netperf_hash[hash_value].hash_lock);
 
   server_pointer = netperf_hash[hash_value].server;
   while (server_pointer != NULL) {
@@ -340,7 +340,7 @@
     server_pointer = server_pointer->next;
   }
 
-  NETPERF_MUTEX_UNLOCK(&(netperf_hash[hash_value].hash_lock));
+  NETPERF_MUTEX_UNLOCK(netperf_hash[hash_value].hash_lock);
 
   return(server_pointer);
 }
@@ -912,7 +912,13 @@
   for (i = 0; i < NETPERF_HASH_BUCKETS; i++) {
     netperf_hash[i].server = NULL;
 #ifdef WITH_GLIB
-    netperf_hash[i].hash_lock = G_STATIC_MUTEX_INIT;
+    netperf_hash[i].hash_lock = g_mutex_new();
+    if (NULL == netperf_hash[i].hash_lock) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_mutex_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
     netperf_hash[i].condition = g_cond_new();
     if (NULL == netperf_hash[i].condition) {
       /* not sure we will even get here */
@@ -921,7 +927,16 @@
       exit(-2);
     }
 #else
-    rc = pthread_mutex_init(&(netperf_hash[i].hash_lock), NULL);
+    netperf_hash[i].hash_lock = 
+      (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+
+    if (NULL == netperf_hash[i].hash_lock) {
+      fprintf(where, "%s: unable to malloc a mutex \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_mutex_init(netperf_hash[i].hash_lock, NULL);
     if (rc) {
       fprintf(where, "%s: server pthread_mutex_init error %d\n", __func__, rc);
       fflush(where);
@@ -949,7 +964,13 @@
   for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
     test_hash[i].test = NULL;
 #ifdef WITH_GLIB
-    test_hash[i].hash_lock = G_STATIC_MUTEX_INIT;
+    test_hash[i].hash_lock = g_mutex_new();
+    if (NULL == test_hash[i].hash_lock) {
+      /* not sure we will even get here */
+      fprintf(where, "%s: g_cond_new error \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
     test_hash[i].condition = g_cond_new();
     if (NULL == test_hash[i].condition) {
       /* not sure we will even get here */
@@ -958,7 +979,16 @@
       exit(-2);
     }
 #else
-    rc = pthread_mutex_init(&(test_hash[i].hash_lock), NULL);
+    test_hash[i].hash_lock = 
+      (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
+
+    if (NULL == test_hash[i].hash_lock) {
+      fprintf(where, "%s: unable to malloc a mutex \n",__func__);
+      fflush(where);
+      exit(-2);
+    }
+
+    rc = pthread_mutex_init(test_hash[i].hash_lock, NULL);
     if (rc) {
       fprintf(where, "%s: test pthread_mutex_init error %d\n", __func__, rc);
       fflush(where);



More information about the netperf-dev mailing list