From 7590c43344e530e3085e494293959aca9cd7e17b Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期三, 23 十二月 2020 17:12:38 +0800
Subject: [PATCH] update

---
 test_net_socket/test_net_mod_socket.c  |    6 +++++-
 src/socket/bus_server_socket_wrapper.c |    4 ++--
 test_net_socket/test_bus_stop.c        |   41 ++++++++++++++++++++++-------------------
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/socket/bus_server_socket_wrapper.c b/src/socket/bus_server_socket_wrapper.c
index 220461e..fc0eb4f 100644
--- a/src/socket/bus_server_socket_wrapper.c
+++ b/src/socket/bus_server_socket_wrapper.c
@@ -17,8 +17,8 @@
  */
 void bus_server_socket_wrapper_close(void *_socket) {
 
-	// BusServerSocket *sockt = (BusServerSocket *)_socket;
-	//delete sockt;
+	BusServerSocket *sockt = (BusServerSocket *)_socket;
+	delete sockt;
 	logger->debug("===bus_server_socket_wrapper_close\n");
 }
 
diff --git a/test_net_socket/test_bus_stop.c b/test_net_socket/test_bus_stop.c
index ed2f60f..a1c20ec 100644
--- a/test_net_socket/test_bus_stop.c
+++ b/test_net_socket/test_bus_stop.c
@@ -8,42 +8,45 @@
 
 static void * server_sockt;
 
+static void sigint_handler(int sig) {
+  bus_server_socket_wrapper_close(server_sockt);
+}
+
 static void *_start_bus_(void *arg) {
- // pthread_detach(pthread_self());
+  pthread_detach(pthread_self());
 	printf("Start bus server\n");
   pthread_t tid;
-
-  server_sockt = bus_server_socket_wrapper_open();
 
   if(bus_server_socket_wrapper_start_bus(server_sockt) != 0) {
     printf("start bus failed\n");
   }
+  printf("============_start_bus_ end\n" );
 }
 
+
 int main() {
-
-
  pthread_t tid;
  char action[512];
-
+ signal(SIGINT,  sigint_handler);
  shm_mm_wrapper_init(512);
+ server_sockt = bus_server_socket_wrapper_open();
  pthread_create(&tid, NULL, _start_bus_,  NULL);
 
 
- while (true) {
-    printf("Input action: Close?\n");
-    if(scanf("%s", action) < 1) {
-      printf("Invalide action\n");
-      continue;
-    }
+ // while (true) {
+ //    printf("Input action: Close?\n");
+ //    if(scanf("%s", action) < 1) {
+ //      printf("Invalide action\n");
+ //      continue;
+ //    }
 
-    if(strcmp(action, "close") == 0) {
-      bus_server_socket_wrapper_close(server_sockt);
-      break;
-    } else {
-      printf("Invalide action\n");
-    }
- }
+ //    if(strcmp(action, "close") == 0) {
+ //      bus_server_socket_wrapper_close(server_sockt);
+ //      break;
+ //    } else {
+ //      printf("Invalide action\n");
+ //    }
+ // }
 
  if (pthread_join(tid, NULL) != 0) {
     perror(" pthread_join");
diff --git a/test_net_socket/test_net_mod_socket.c b/test_net_socket/test_net_mod_socket.c
index 5693cf6..2b2a56a 100644
--- a/test_net_socket/test_net_mod_socket.c
+++ b/test_net_socket/test_net_mod_socket.c
@@ -85,7 +85,7 @@
 
 
 void *bus_handler(void *sockt) {
-  pthread_detach(pthread_self());
+  // pthread_detach(pthread_self());
   
   char action[512];
   while ( true) {
@@ -119,6 +119,10 @@
     printf("start bus failed\n");
     exit(1);
   }
+
+  if (pthread_join(tid, NULL) != 0) {
+    perror(" pthread_join");
+  }
 }
 
  

--
Gitblit v1.8.0