From 2561a007b8d8999a4750046d0cfb3b1ad5af50ac Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 09 四月 2024 15:29:32 +0800
Subject: [PATCH] test for perf

---
 test_socket/bus_test.cpp |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/test_socket/bus_test.cpp b/test_socket/bus_test.cpp
index a6d741e..d2ead68 100644
--- a/test_socket/bus_test.cpp
+++ b/test_socket/bus_test.cpp
@@ -3,7 +3,12 @@
 #include "shm_mm_wrapper.h"
 #include "usg_common.h"
 #include "mm.h"
+#include "logger_factory.h"
+ 
+#include "bus_error.h"
 
+static Logger *logger = LoggerFactory::getLogger();
+ 
 BusServerSocket * server_socket;
 void sigint_handler(int sig) {
   
@@ -24,14 +29,15 @@
   void *recvbuf;
   int size;
   int key;
+
   int rv;
   ShmModSocket *sk = (ShmModSocket *)skptr;
-printf("run_recv\n");
   struct timespec timeout = {2, 0};
   while (true) {
     printf("run_recv before\n");
 
-    rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout);
+    // rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout);
+    rv = sk->recvfrom( &recvbuf, &size, &key);
     if(rv == 0) {
       printf("鏀跺埌璁㈤槄娑堟伅:%s\n", recvbuf);
       free(recvbuf);
@@ -44,27 +50,26 @@
   
 }
 
-void client2(int key) {
-  ShmModSocket *sk = new ShmModSocket();
-  run_recv((void *)sk);
-}
-
 void client(int key) {
   ShmModSocket *sk = new ShmModSocket();
   
   pthread_t tid;
-  pthread_create(&tid, NULL, run_recv, (void *)sk);
+
+
   int size;
   
   char action[512];
   char topic[512];
   char content[512];
   long i = 0;
+
+  pthread_create(&tid, NULL, run_recv, (void *)sk);
+
   while (true) {
     //printf("Usage: pub <topic> [content] or sub <topic>\n");
-    printf("Can I help you? sub, pub, desub or quit\n");
-    scanf("%s",action);
-    
+    printf("Can I help you? sub, pub, desub or quit %d\n", i++);
+    // scanf("%s", action);
+    std::cin >> action;
     if(strcmp(action, "sub") == 0) {
       printf("Please input topic!\n");
       scanf("%s", topic);
@@ -130,4 +135,4 @@
 
   
   return 0;
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0