From d5e7001c1e58e39e727361be096b2b654b1e9e70 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期三, 02 十二月 2020 10:02:25 +0800
Subject: [PATCH] update

---
 test_net_socket/test_net_mod_socket.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/test_net_socket/test_net_mod_socket.c b/test_net_socket/test_net_mod_socket.c
index 8dafcfc..9ce8272 100644
--- a/test_net_socket/test_net_mod_socket.c
+++ b/test_net_socket/test_net_mod_socket.c
@@ -4,6 +4,8 @@
 #include "usg_common.h"
 #include <getopt.h>
 
+#define  SCALE  100000
+
 typedef struct Targ {
 	char *nodelist;
 	int id;
@@ -24,6 +26,10 @@
 void usage(char *name);
 int parse_node_list(char *str, net_node_t *node_arr_addr[]) ;
 void print_node_list(net_node_t *node_arr, int len);
+
+
+
+void * client;
 
 void start_net_proxy(int port) {
   printf("Start net proxy\n");
@@ -47,7 +53,7 @@
 }
 
 void start_net_client(char *sendlist, char*publist ){
-	void * client = net_mod_socket_open();
+	client = net_mod_socket_open();
 	char content[MAXLINE];
 	char action[512];
   char topic[512];
@@ -172,7 +178,7 @@
 
  
 
-#define  SCALE  100000
+
 
 void *_run_sendandrecv_(void *arg) {
   Targ *targ = (Targ *)arg;
@@ -187,8 +193,6 @@
   int node_arr_size = parse_node_list(targ->nodelist, &node_arr);
  
 
-  void * client = net_mod_socket_open();
-	
 	char filename[512];
 	sprintf(filename, "test%d.tmp", targ->id);
 	FILE *fp = NULL;
@@ -215,7 +219,7 @@
     total += n;
   }
   fclose(fp);
-  net_mod_socket_close(client);
+  
   return (void *)total;
 }
 
@@ -230,6 +234,7 @@
   struct timeval start, end;
   long total = 0;
   
+  client = net_mod_socket_open();
   printf("寮�濮嬫祴璇�...\n");  
   gettimeofday(&start, NULL);
   for (i = 0; i < processors; i++) {
@@ -254,6 +259,7 @@
   long diffusec = difftime - diffsec*1000000;
   fprintf(stderr,"鍙戦�佹暟鐩�: %ld, 鐢ㄦ椂: (%ld sec %ld usec), 骞冲潎: %f\n", total, diffsec, diffusec, difftime/total );
   // fflush(stdout);
+  net_mod_socket_close(client);
 }
 
 
@@ -269,7 +275,7 @@
  
   char *topic = "news";
 
-  void * client = net_mod_socket_open();
+ 
   
   // char filename[512];
   // sprintf(filename, "test%d.tmp", targ->id);
@@ -287,7 +293,7 @@
     total += n;
   }
   // fclose(fp);
-  net_mod_socket_close(client);
+ 
   return (void *)total;
 }
 
@@ -301,6 +307,7 @@
   char sendbuf[512];
   struct timeval start, end;
   long total = 0;
+  client = net_mod_socket_open();
   
 printf("寮�濮嬫祴璇�...\n");  
   gettimeofday(&start, NULL);
@@ -326,6 +333,7 @@
   long diffusec = difftime - diffsec*1000000;
   fprintf(stderr,"鍙戦�佹暟鐩�: %ld, 鐢ㄦ椂: (%ld sec %ld usec), 骞冲潎: %f\n", total, diffsec, diffusec, difftime/total );
   // fflush(stdout);
+  net_mod_socket_close(client);
 }
 
 

--
Gitblit v1.8.0