[netperf-dev] netperf2 commit notice r299 - in trunk/src: . NetPerfDir NetServerDir

raj at netperf.org raj at netperf.org
Tue Apr 7 15:44:14 PDT 2009


Author: raj
Date: 2009-04-07 15:44:13 -0700 (Tue, 07 Apr 2009)
New Revision: 299

Modified:
   trunk/src/NetPerfDir/sources
   trunk/src/NetServerDir/sources
   trunk/src/netcpu_ntperf.c
   trunk/src/netlib.c
   trunk/src/netserver.c
   trunk/src/nettest_bsd.c
Log:
more windows fixes at least that is the idea

Modified: trunk/src/NetPerfDir/sources
===================================================================
--- trunk/src/NetPerfDir/sources	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/NetPerfDir/sources	2009-04-07 22:44:13 UTC (rev 299)
@@ -16,12 +16,13 @@
 
 C_DEFINES=$(C_DEFINES) -D_CONSOLE_ -DHAVE_STRUCT_SOCKADDR_STORAGE -DHAVE_GETADDRINFO -DHAVE_GETNAMEINFO -DSTDC_HEADERS
 
+#USER_C_FLAGS=$(USER_C_FLAGS) /E
+
 SOURCES= \
         ..\netcpu_ntperf.c \
 	..\netlib.c \
 	..\netsh.c \
 	..\nettest_bsd.c \
-	inet_ntop.c \
 	..\netperf.c
 
 

Modified: trunk/src/NetServerDir/sources
===================================================================
--- trunk/src/NetServerDir/sources	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/NetServerDir/sources	2009-04-07 22:44:13 UTC (rev 299)
@@ -16,11 +16,12 @@
 
 C_DEFINES=$(C_DEFINES) -D_CONSOLE_ -DHAVE_STRUCT_SOCKADDR_STORAGE -DHAVE_GETADDRINFO -DHAVE_GETNAMEINFO -DSTDC_HEADERS
 
+#USER_C_FLAGS=$(USER_C_FLAGS) /E
+
 SOURCES= \
         ..\netcpu_ntperf.c \
 	..\netlib.c \
 	..\netsh.c \
 	..\nettest_bsd.c \
-	inet_ntop.c \
 	..\netserver.c
 

Modified: trunk/src/netcpu_ntperf.c
===================================================================
--- trunk/src/netcpu_ntperf.c	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/netcpu_ntperf.c	2009-04-07 22:44:13 UTC (rev 299)
@@ -285,7 +285,7 @@
 {
   double tot_CPU_Util;
   int i;
-  int duration;  // in 100 usecs
+  double duration;  // in milliseconds
   
   LARGE_INTEGER ActualDuration;
   
@@ -327,13 +327,13 @@
   ActualDuration.QuadPart = PerfCntrs->EndTime.QuadPart - 
     PerfCntrs->StartTime.QuadPart;
   
-  // convert to 1/10 milliseconds (100 usec) 
+  // convert to 100 usec (1/10th milliseconds) timebase.
   ActualDuration.QuadPart = (ActualDuration.QuadPart*10000)/TickHz.QuadPart;
-  duration = ActualDuration.LowPart;
+  duration = (double)ActualDuration.QuadPart/10.0;  // duration in ms
   
   if (verbosity > 1)
     {
-      fprintf(where,"ActualDuration (ms): %d\n", duration/10);
+      fprintf(where,"ActualDuration (ms): %d\n", (int)duration);
     }
   
   if (verbosity > 1)
@@ -412,14 +412,14 @@
       fprintf(where, "\n\n");
       
       fprintf(where, "Interrupt/Sec. %5.1f", 
-	      (double)DeltaInfo[MAXCPUS].InterruptCount*10000.0/(double)duration);
+	      (double)DeltaInfo[MAXCPUS].InterruptCount*1000.0/duration);
       
       if ((int)SystemInfo.dwNumberOfProcessors > 1)
 	{
 	  for (i=0; i < (int)SystemInfo.dwNumberOfProcessors; i++)
 	    {
 	      fprintf(where, "\t %5.1f", 
-		      (double)DeltaInfo[i].InterruptCount*10000.0/(double)duration);
+		      (double)DeltaInfo[i].InterruptCount*1000.0/duration);
 	    }
 	}
       fprintf(where, "\n\n");

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/netlib.c	2009-04-07 22:44:13 UTC (rev 299)
@@ -114,6 +114,8 @@
 
 #include <windows.h>
 
+#define strdup _strdup
+
 #define SIGALRM (14)
 #define sleep(x) Sleep((x)*1000)
 
@@ -923,6 +925,7 @@
 emulate_alarm( int seconds )
 {
 	DWORD ErrorCode;
+	DWORD HandlesClosedFlags = 0;
 
 	/* Wait on this event for parm seconds. */
 
@@ -940,22 +943,39 @@
 
         times_up = 1;
 
-        /* We have yet to find a good way to fully emulate the effects */
-        /* of signals and getting EINTR from system calls under */
-        /* winsock, so what we do here is close the socket out from */
-        /* under the other thread.  It is rather kludgy, but should be */
-        /* sufficient to get this puppy shipped.  The concept can be */
-        /* attributed/blamed :) on Robin raj 1/96 */
+		// Give the other threads time to notice that times_up
+	        // has changed state before taking the harsh step of
+	        // closing the sockets.
 
-        if (win_kludge_socket != INVALID_SOCKET) {
-          closesocket(win_kludge_socket);
-        }
-        if (win_kludge_socket2 != INVALID_SOCKET) {
-          closesocket(win_kludge_socket2);
-        }
+		if (WaitForSingleObject(hAlarm, PAD_TIME/2*1000) ==
+		    WAIT_TIMEOUT) {
+		  /* We have yet to find a good way to fully emulate
+		     the effects of signals and getting EINTR from
+		     system calls under winsock, so what we do here is
+		     close the socket out from under the other thread.
+		     It is rather kludgy, but should be sufficient to
+		     get this puppy shipped.  The concept can be
+		     attributed/blamed :) on Robin raj 1/96 */
+
+		  if (win_kludge_socket != INVALID_SOCKET) {
+		    HandlesClosedFlags |= 1;
+		    closesocket(win_kludge_socket);
+		  }
+		  if (win_kludge_socket2 != INVALID_SOCKET) {
+		    HandlesClosedFlags |= 1;
+		    closesocket(win_kludge_socket2);
+		  }
+		}
+		if(debug) {
+		  fprintf(where,
+			  "emulate_alarm - HandlesClosedFlags: %x\n",
+			  HandlesClosedFlags);
+		  fflush(where);
+		}
 	}
 }
 
+
 #endif /* WIN32 */
 
 void
@@ -4439,19 +4459,19 @@
 double
 get_result_confid()
 {
-  return 100.0 * (interval - result_confid);
+  return (double) (100.0 * (interval - result_confid));
 }
 
 double
 get_loc_cpu_confid()
 {
-  return 100.0 * (interval - loc_cpu_confid);
+  return (double) (100.0 * (interval - loc_cpu_confid));
 }
 
 double
 get_rem_cpu_confid()
 {
-  return 100.0 * (interval - rem_cpu_confid);
+  return (double) (100.0 * (interval - rem_cpu_confid));
 }
 
  /* display_confidence() is called when we could not achieve the */

Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/netserver.c	2009-04-07 22:44:13 UTC (rev 299)
@@ -102,6 +102,7 @@
 #include <ws2tcpip.h>
 #endif  /* DONT_IPV6 */
 #include <windows.h>
+#define strdup _strdup
 #define sleep(x) Sleep((x)*1000)
 #else
 #ifndef MPE

Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c	2009-04-07 21:49:21 UTC (rev 298)
+++ trunk/src/nettest_bsd.c	2009-04-07 22:44:13 UTC (rev 299)
@@ -1022,8 +1022,8 @@
   switch (family) {
   case AF_INET: {
     struct sockaddr_in *foo = (struct sockaddr_in *)sockaddr;
-    foo->sin_port = htons(port);
-    foo->sin_family = family;
+    foo->sin_port = htons((unsigned short) port);
+    foo->sin_family = (unsigned short) family;
     memcpy(&(foo->sin_addr),addr,sizeof(foo->sin_addr));
     *(int *)addr = htonl(*(int *)addr);
     break;
@@ -1033,8 +1033,8 @@
     struct sockaddr_in6 *foo = (struct sockaddr_in6 *)sockaddr;
     int *bar;
     int i;
-    foo->sin6_port = htons(port);
-    foo->sin6_family = family;
+    foo->sin6_port = htons((unsigned short) port);
+    foo->sin6_family = (unsigned short) family;
     memcpy(&(foo->sin6_addr),addr,sizeof(foo->sin6_addr));
     /* how to put this into "host" order? */
     for (i = sizeof(foo->sin6_addr)/sizeof(int), bar=addr; i > 0; i--) {
@@ -1079,8 +1079,8 @@
   case AF_INET6: {
     int *foo;
     int i;
+    struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sockaddr;
     ret = 0;
-    struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sockaddr;
     *port = ntohs(sin6->sin6_port);
     memcpy(addr,&(sin6->sin6_addr), sizeof(sin6->sin6_addr));
     /* how to put this into "host" order? */
@@ -1426,10 +1426,12 @@
 }
 
 #if defined(WIN32) 
+#if !defined(InetNtop)
 /* +*+ Why isn't this in the winsock headers yet? */
 const char *
 inet_ntop(int af, const void *src, char *dst, size_t size);
 #endif
+#endif
 
 /* This routine is a generic test header printer for the topmost header */
 void
@@ -1810,6 +1812,16 @@
       exit(1);
     }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
     /* Data Socket set-up is finished. If there were problems, either */
     /* the connect would have failed, or the previous response would */
     /* have indicated a problem. I failed to see the value of the */
@@ -2506,6 +2518,16 @@
       exit(1);
     }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = recv_socket;
+#endif /* WIN32 */
+
     /* Data Socket set-up is finished. If there were problems, either */
     /* the connect would have failed, or the previous response would */
     /* have indicated a problem. I failed to see the value of the */
@@ -3425,6 +3447,16 @@
                 exit(1);
             }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
         /* Data Socket set-up is finished. If there were problems, either */
         /* the connect would have failed, or the previous response would */
         /* have indicated a problem. I failed to see the value of the */
@@ -4230,6 +4262,16 @@
       exit(1);
     }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
     /* Data Socket set-up is finished. If there were problems, either
        the connect would have failed, or the previous response would
        have indicated a problem. I failed to see the value of the
@@ -4928,6 +4970,21 @@
     exit(1);
   }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = s_data;
+  win_kludge_socket2 = INVALID_SOCKET;
+#endif /* WIN32 */
+
+  times_up = 0;
+
+  start_timer(tcp_stream_request->test_length + PAD_TIME);
+
 #ifdef KLUDGE_SOCKET_OPTIONS
   /* this is for those systems which *INCORRECTLY* fail to pass */
   /* attributes across an accept() call. Including this goes against */
@@ -4954,7 +5011,7 @@
   bytes_received = 0;
   receive_calls  = 0;
 
-  while ((len = recv(s_data, recv_ring->buffer_ptr, recv_size, 0)) != 0) {
+  while (!times_up && ((len = recv(s_data, recv_ring->buffer_ptr, recv_size, 0)) != 0)) {
     if (len == SOCKET_ERROR )
 	{
       netperf_response.content.serv_errno = errno;
@@ -5274,6 +5331,17 @@
     exit(1);
   }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = s_data;
+  win_kludge_socket2 = INVALID_SOCKET;
+#endif /* WIN32 */
+
 #ifdef KLUDGE_SOCKET_OPTIONS
   
   /* this is for those systems which *INCORRECTLY* fail to pass
@@ -5703,6 +5771,16 @@
       exit(1);
     }
     
+#ifdef WIN32
+    /* this is used so the timer thread can close the socket out from */
+    /* under us, which to date is the easiest/cleanest/least */
+    /* Windows-specific way I can find to force the winsock calls to */
+    /* return WSAEINTR with the test is over. anything that will run on */
+    /* 95 and NT and is closer to what netperf expects from Unix signals */
+    /* and such would be appreciated raj 1/96 */
+    win_kludge_socket = recv_socket;
+#endif /* WIN32 */
+
     /* Data Socket set-up is finished. If there were problems, either the */
     /* connect would have failed, or the previous response would have */
     /* indicated a problem. I failed to see the value of the extra */
@@ -6417,6 +6495,16 @@
        }
     }
     
+#ifdef WIN32
+   /* this is used so the timer thread can close the socket out from
+      under us, which to date is the easiest/cleanest/least
+      Windows-specific way I can find to force the winsock calls to
+      return WSAEINTR with the test is over. anything that will run on
+      95 and NT and is closer to what netperf expects from Unix
+      signals and such would be appreciated raj 1/96 */
+    win_kludge_socket = data_socket;
+#endif /* WIN32 */
+
     /* set up the timer to call us after test_time. one of these days, */
     /* it might be nice to figure-out a nice reliable way to have the */
     /* test controlled by a byte count as well, but since UDP is not */
@@ -7354,13 +7442,6 @@
     /* Set-up the test end conditions. For a request/response test, they */
     /* can be either time or transaction based. */
 
-#ifdef WIN32
-	/* The test timer can fire during recv operations on the socket,
-	   so to make the start_timer below work we have to move
-       it to close send_socket while we are blocked on recv. */
-	win_kludge_socket = send_socket;
-#endif /* WIN32 */   
-
     if (test_time) {
       /* The user wanted to end the test after a period of time. */
       times_up = 0;
@@ -10923,6 +11004,26 @@
       exit(1);
     }
 
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
+#ifdef WIN32
+  /* this is used so the timer thread can close the socket out from */
+  /* under us, which to date is the easiest/cleanest/least */
+  /* Windows-specific way I can find to force the winsock calls to */
+  /* return WSAEINTR with the test is over. anything that will run on */
+  /* 95 and NT and is closer to what netperf expects from Unix signals */
+  /* and such would be appreciated raj 1/96 */
+  win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
     /* Data Socket set-up is finished. If there were problems, either the */
     /* connect would have failed, or the previous response would have */
     /* indicated a problem. I failed to see the value of the extra */
@@ -11991,6 +12092,16 @@
       exit(1);
     }
 
+#ifdef WIN32
+    /* this is used so the timer thread can close the socket out from */
+    /* under us, which to date is the easiest/cleanest/least */
+    /* Windows-specific way I can find to force the winsock calls to */
+    /* return WSAEINTR with the test is over. anything that will run on */
+    /* 95 and NT and is closer to what netperf expects from Unix signals */
+    /* and such would be appreciated raj 1/96 */
+    win_kludge_socket = send_socket;
+#endif /* WIN32 */
+
     /* we used to have a call to bind() here, but that is being
        taken care of by create_data_socket(). raj 2005-02-08 */
 
@@ -12535,6 +12646,7 @@
   /* 95 and NT and is closer to what netperf expects from Unix signals */
   /* and such would be appreciated raj 1/96 */
   win_kludge_socket = s_data;
+  win_kludge_socket2 = INVALID_SOCKET;
 #endif /* WIN32 */
 
     if (debug) {



More information about the netperf-dev mailing list