[netperf-dev] netperf4 commit notice r83 - branches/glib_migration/src

raj at netperf.org raj at netperf.org
Thu Mar 16 17:16:00 PST 2006


Author: raj
Date: 2006-03-16 17:15:57 -0800 (Thu, 16 Mar 2006)
New Revision: 83

Modified:
   branches/glib_migration/src/netlib.c
   branches/glib_migration/src/netmsg.c
   branches/glib_migration/src/netperf.c
   branches/glib_migration/src/netperf.h
   branches/glib_migration/src/netserver.c
   branches/glib_migration/src/netsysstats_common.c
   branches/glib_migration/src/nettest_bsd.c
Log:
Additional, small, Windows cleanups.


Modified: branches/glib_migration/src/netlib.c
===================================================================
--- branches/glib_migration/src/netlib.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netlib.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -1375,7 +1375,7 @@
     }
     fprintf(where,"establish_listen: bind error close and try next\n");
     fflush(where);
-    close(sockfd);
+    CLOSE_SOCKET(sockfd);
   } while ( (res_temp = res_temp->ai_next) != NULL );
 
   if (res_temp == NULL) {
@@ -1385,7 +1385,7 @@
   } else if (listen (sockfd,20) == -1) {
     fprintf(where,"establish_listen: setting the listen backlog failed\n");
     fflush(where);
-    close(sockfd);
+    CLOSE_SOCKET(sockfd);
     sockfd = -1;
   } else {
     if (addrlenp) *addrlenp = res_temp->ai_addrlen;
@@ -1603,7 +1603,7 @@
          don't worry about overheads for socket allocation or
          close. raj 2003-02-24 */
     }
-    close(control_sock);
+    CLOSE_SOCKET(control_sock);
   }
 
   /* we no longer need the addrinfo stuff */

Modified: branches/glib_migration/src/netmsg.c
===================================================================
--- branches/glib_migration/src/netmsg.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netmsg.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -198,7 +198,7 @@
           fflush(where);
           server->state = NSRV_ERROR;
           if (server->sock != -1) {
-            close(server->sock);
+            CLOSE_SOCKET(server->sock);
             /* should we delete the server from the server_hash ? sgb */
             break;
           }
@@ -969,7 +969,7 @@
                   new_test->thread_id);
           fflush(where);
         }
-        sleep(1);
+        g_usleep(1000000);
       }  /* end wait */
       if (debug) {
         fprintf(where,

Modified: branches/glib_migration/src/netperf.c
===================================================================
--- branches/glib_migration/src/netperf.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netperf.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -1431,7 +1431,7 @@
           }
           if (i) {
             i--;
-            sleep(1);
+            g_usleep(1000000);
           }
           else {
             i = 15;
@@ -1453,7 +1453,7 @@
         }
         if (i) {
           i--;
-          sleep(1);
+          g_usleep(1000000);
         }
         else {
           i = 15;
@@ -2005,7 +2005,7 @@
     seconds = 0;
   }
   if (seconds) {
-    sleep(seconds);
+    g_usleep(seconds*1000000);
   }
   return(NPE_SUCCESS);
 }
@@ -2040,7 +2040,7 @@
   while ((server->state != NSRV_ERROR) &&
          (server->state != NSRV_CLOSE) &&
          (server->state != NSRV_EXIT ))  {
-    sleep(1);
+    g_usleep(1000000);
   }
   delete_server(sid);
   return(rc);

Modified: branches/glib_migration/src/netperf.h
===================================================================
--- branches/glib_migration/src/netperf.h	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netperf.h	2006-03-17 01:15:57 UTC (rev 83)
@@ -117,10 +117,11 @@
 #define NETPERF_DEBUG_LOG_PREFIX  "netperf"
 #define NETPERF_DEBUG_LOG_SUFFIX  ".log"
 #define netperf_socklen_t socklen_t
-#define close(x) closesocket(x)
 #define CLOSE_SOCKET(x) closesocket(x)
 #define strcasecmp(a,b) _stricmp(a,b)
 #define getpid() ((int)GetCurrentProcessId())
+#define __func__ __FUNCTION__
+#define PATH_MAX MAXPATHLEN
 #else
 #define NETPERF_DEBUG_LOG_DIR "/tmp/"
 #define NETPERF_DEBUG_LOG_PREFIX  "netperf"
@@ -129,6 +130,7 @@
 #define SOCKET_ERROR -1
 #define SOCKET int
 #define CLOSE_SOCKET(x) close(x)
+#define GET_ERRNO errno
 #endif
 
 #include "netconfidence.h"
@@ -174,6 +176,9 @@
         (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR)
 #define GET_ERRNO WSAGetLastError()
 #define NETPERF_PATH_SEP "\\"
+#ifndef SHUT_WR
+#define SHUT_WR SD_SEND
+#endif
 #else
 #define CHECK_FOR_NOT_SOCKET (errno == ENOTSOCK)
 #define CHECK_FOR_INVALID_SOCKET (temp_socket < 0)

Modified: branches/glib_migration/src/netserver.c
===================================================================
--- branches/glib_migration/src/netserver.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netserver.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -158,7 +158,7 @@
 gboolean set_port_number(gchar *option_name, gchar *option_value, gpointer data, GError **error) {
 
   listen_port = g_strdup(option_value);
-  listen_port_num = atoi(listen_port);
+  listen_port_num = (guint16)atoi(listen_port);
 
   return(TRUE);
 
@@ -624,7 +624,7 @@
         g_fprintf(where,"%s: close connection remote close\n", __func__);
         fflush(where);
       }
-      close(sock);
+      CLOSE_SOCKET(sock);
       exit(-1);
     }
     if (rc == NPE_SUCCESS) {
@@ -787,7 +787,7 @@
   empty_hash_buckets = 0;
   while(empty_hash_buckets < TEST_HASH_BUCKETS) {
     empty_hash_buckets = 0;
-    sleep(1);
+    g_usleep(1000000);
     check_test_state();
     for (i = 0; i < TEST_HASH_BUCKETS; i ++) {
       if (test_hash[i].test == NULL) {

Modified: branches/glib_migration/src/netsysstats_common.c
===================================================================
--- branches/glib_migration/src/netsysstats_common.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/netsysstats_common.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -68,8 +68,6 @@
 
 #include "netperf.h"
 
-#define GET_ERRNO errno
-
 #include "netsysstats.h"
 
 /* variables are kept in the test_specific data section of the test stucture.
@@ -304,13 +302,13 @@
                        cpu_time_counters_t *cpu,
                        uint32_t num_cpus)
 {
-  int        i;
+  uint32_t        i;
   xmlNodePtr cpu_stats = NULL;
   xmlAttrPtr ap        = NULL;
 
   NETPERF_DEBUG_ENTRY(test->debug,test->where);
   
-  for (i=0;i<num_cpus;i++) {
+  for (i = 0; i < num_cpus; i++) {
     if ((cpu_stats = xmlNewNode(NULL,(xmlChar *)"per_cpu_stats")) != NULL) {
       /* set the properites of the per_cpu_stats -
          the cpu_id counter values  sgb 2005-10-17 */
@@ -550,7 +548,7 @@
 	}
 	/* check for state transition */
 	if (CHECK_REQ_STATE == TEST_IDLE) {
-	  sleep(1);
+	  g_usleep(1000000);
 	} else if (CHECK_REQ_STATE == TEST_LOADED) {
 	  SET_TEST_STATE(TEST_LOADED);
 	} else if (CHECK_REQ_STATE == TEST_DEAD) {
@@ -569,7 +567,7 @@
 	}
 	
 	if (CHECK_REQ_STATE == TEST_MEASURE) {
-	  sleep(1);
+	  g_usleep(1000000);
 	} else if (CHECK_REQ_STATE == TEST_LOADED) {
 	  /* get_cpu_time_counters sets current timestamp */
 	  get_cpu_time_counters(tsd->ending_cpu_counters,&(tsd->curr_time),test);
@@ -589,7 +587,7 @@
 	}
 	
 	if (CHECK_REQ_STATE == TEST_LOADED) {
-	  sleep(1);
+	  g_usleep(1000000);
 	} else if (CHECK_REQ_STATE == TEST_MEASURE) {
 	  /* transitioning to measure state from loaded state set
 	     get_cpu_time_counters sets previous timestamp */
@@ -615,7 +613,7 @@
     /* do we ever get here? seems that if we do, it would be spinning
        like crazy?!?  raj 2005-10-06 */
     while (GET_TEST_STATE != TEST_DEAD) {
-      sleep(1);
+      g_usleep(1000000);
       if (CHECK_REQ_STATE == TEST_DEAD) {
 	SET_TEST_STATE(TEST_DEAD);
       }

Modified: branches/glib_migration/src/nettest_bsd.c
===================================================================
--- branches/glib_migration/src/nettest_bsd.c	2006-03-16 23:53:04 UTC (rev 82)
+++ branches/glib_migration/src/nettest_bsd.c	2006-03-17 01:15:57 UTC (rev 83)
@@ -123,6 +123,18 @@
 #include <netdb.h>
 #endif
 
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
 #include "netperf.h"
 
 #include "nettest_bsd.h"
@@ -130,12 +142,10 @@
 #ifdef WIN32
 #define CHECK_FOR_INVALID_SOCKET (temp_socket == INVALID_SOCKET)
 #define CHECK_FOR_RECV_ERROR(len) (len == SOCKET_ERROR)
-#define CHECK_FOR_SEND_ERROR(len) (len >=0) || (len == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) 
 #define GET_ERRNO WSAGetLastError()
 #else
 #define CHECK_FOR_INVALID_SOCKET (temp_socket < 0)
 #define CHECK_FOR_RECV_ERROR(len) (len < 0)
-#define CHECK_FOR_SEND_ERROR(len) (len >=0) || (errno == EINTR)
 #define GET_ERRNO errno
 #endif
 
@@ -282,7 +292,7 @@
     case TEST_IDLE:
       new_state = CHECK_REQ_STATE;
       if (new_state == TEST_IDLE) {
-        sleep(1);
+        g_usleep(1000000);
       }
       break;
     case TEST_MEASURE:
@@ -398,7 +408,7 @@
         fprintf(test->where,"Sleeping on getaddrinfo EAI_AGAIN\n");
         fflush(test->where);
       }
-      sleep(1);
+      g_usleep(1000000);
     }
   } while ((error == EAI_AGAIN) && (count <= 5));
     
@@ -643,7 +653,7 @@
 #ifdef SO_SNDBUF
   if (lss_size > 0) {
     if(setsockopt(temp_socket, SOL_SOCKET, SO_SNDBUF,
-                  &lss_size, sizeof(int)) < 0) {
+                  (void *)&lss_size, sizeof(int)) < 0) {
       report_test_failure(test,
                           "create_data_socket",
                           BSDE_SETSOCKOPT_ERROR,
@@ -660,7 +670,7 @@
 
   if (lsr_size > 0) {
     if(setsockopt(temp_socket, SOL_SOCKET, SO_RCVBUF,
-                  &lsr_size, sizeof(int)) < 0) {
+                  (void *)&lsr_size, sizeof(int)) < 0) {
       report_test_failure(test,
                           "create_data_socket",
                           BSDE_SETSOCKOPT_ERROR,
@@ -928,7 +938,7 @@
           fprintf(test->where,"Sleeping on getaddrinfo EAI_AGAIN\n");
           fflush(test->where);
         }
-        sleep(1);
+        g_usleep(1000000);
       }
     } while ((error == EAI_AGAIN) && (count <= 5));
     
@@ -1226,7 +1236,7 @@
     fflush(test->where);
   }
   while (new_state == TEST_LOADED) {
-    sleep(1);
+    g_usleep(1000000);
     new_state = CHECK_REQ_STATE;
   }
   if (test->debug) {
@@ -1240,7 +1250,7 @@
                           BSDE_SOCKET_SHUTDOWN_FAILED,
                           "failure shuting down data socket");
     } else {
-      close(my_data->s_data);
+      CLOSE_SOCKET(my_data->s_data);
       if (test->debug) {
         fprintf(test->where,"%s: waiting in accept\n",proc_name);
         fflush(test->where);
@@ -1442,7 +1452,7 @@
     recv(my_data->s_data,
          my_data->send_ring->buffer_ptr,
          my_data->send_size, 0);
-    close(my_data->s_data);
+    CLOSE_SOCKET(my_data->s_data);
     my_data->s_data = create_data_socket(test);
     if (test->debug) {
       fprintf(test->where,"%s: connecting from LOAD state\n",proc_name);
@@ -1617,7 +1627,7 @@
     case TEST_IDLE:
       new_state = CHECK_REQ_STATE;
       if (new_state == TEST_IDLE) {
-        sleep(1);
+        g_usleep(1000000);
       }
       break;
     case TEST_MEASURE:
@@ -1664,7 +1674,7 @@
     case TEST_IDLE:
       new_state = CHECK_REQ_STATE;
       if (new_state == TEST_IDLE) {
-        sleep(1);
+        g_usleep(1000000);
       }
       break;
     case TEST_MEASURE:
@@ -1799,7 +1809,7 @@
 
   new_state = CHECK_REQ_STATE;
   while (new_state == TEST_LOADED) {
-    sleep(1);
+    g_usleep(1000000);
     new_state = CHECK_REQ_STATE;
   }
 
@@ -1819,7 +1829,7 @@
                  my_data->recv_ring->buffer_ptr,
                  my_data->req_size, 0);
       }
-      close(my_data->s_data);
+      CLOSE_SOCKET(my_data->s_data);
       if (test->debug) {
         fprintf(test->where,"%s: waiting in accept\n",proc_name);
         fflush(test->where);
@@ -2059,7 +2069,7 @@
 
   new_state = CHECK_REQ_STATE;
   while (new_state == TEST_LOADED) {
-    sleep(1);
+    g_usleep(1000000);
     new_state = CHECK_REQ_STATE;
   }
   if (new_state == TEST_IDLE) {
@@ -2078,7 +2088,7 @@
                    my_data->recv_ring->buffer_ptr,
                    my_data->rsp_size, 0);
       }
-      close(my_data->s_data);
+      CLOSE_SOCKET(my_data->s_data);
       my_data->s_data = create_data_socket(test);
       if (test->debug) {
         fprintf(test->where,"%s: connecting from LOAD state\n",proc_name);
@@ -2319,7 +2329,7 @@
     case TEST_IDLE:
       new_state = CHECK_REQ_STATE;
       if (new_state == TEST_IDLE) {
-        sleep(1);
+        g_usleep(1000000);
       }
       break;
     case TEST_MEASURE:
@@ -2366,7 +2376,7 @@
     case TEST_IDLE:
       new_state = CHECK_REQ_STATE;
       if (new_state == TEST_IDLE) {
-        sleep(1);
+        g_usleep(1000000);
       }
       break;
     case TEST_MEASURE:



More information about the netperf-dev mailing list