From 6de74d5e60a9a5ecd417a5473a3b567e51ca2de8 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期一, 25 一月 2021 15:14:23 +0800
Subject: [PATCH] update

---
 lib/libusgcommon.a                      |    0 
 test_socket/bus_test.cpp                |   17 ++++++++++-------
 test_net_socket/test_net_mod_socket.cpp |    2 +-
 include/usgcommon/logger.h              |   27 +--------------------------
 src/socket/shm_socket.cpp               |    5 -----
 5 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/include/usgcommon/logger.h b/include/usgcommon/logger.h
index 61d6e02..ccf17cd 100644
--- a/include/usgcommon/logger.h
+++ b/include/usgcommon/logger.h
@@ -16,32 +16,7 @@
   LoggerConfig config;
   FILE *logFile;
 
-  void dolog(const char *fmt, va_list ap, int level, int err = 0) {
-    char buf[MAXLINE];
-
-    struct timeval tv;
-    struct tm *info;
-    gettimeofday(&tv, NULL);
-    info = localtime(&tv.tv_sec);
-    strftime(buf, MAXBUF - 1, "%Y-%d-%m %H:%M:%S", info);
-    snprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, ",%ld [%s] ",  tv.tv_usec, strlevel(level));
-    vsnprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, fmt, ap);
-
-    if (err != 0) {
-      snprintf(buf + strlen(buf), MAXBUF - strlen(buf) - 1, ": %s", strerror(err));
-    }
-    strcat(buf, "\n");
-    fflush(stdout); /* in case stdout and stderr are the same */
-    
-    if(logFile != NULL) {
-      fputs(buf, logFile);
-    }
-    if(config.console) {
-       fputs(buf, stdout);
-    }
-   
-    fflush(NULL); /* flushes all stdio output streams */
-  }
+  void dolog(const char *fmt, va_list ap, int level, int err = 0);
 
   
   void init();
diff --git a/lib/libusgcommon.a b/lib/libusgcommon.a
index 67ec843..9d121d2 100644
--- a/lib/libusgcommon.a
+++ b/lib/libusgcommon.a
Binary files differ
diff --git a/src/socket/shm_socket.cpp b/src/socket/shm_socket.cpp
index 25c3930..3e5577b 100644
--- a/src/socket/shm_socket.cpp
+++ b/src/socket/shm_socket.cpp
@@ -384,9 +384,6 @@
   }
 }
 
-int shm_recvfrom2(shm_socket_t *socket, void **buf, int *size, int *key,  const struct timespec *timeout,  int flag) {
-  return 501;
-}
 
 // 鐭繛鎺ユ柟寮忔帴鍙�
 int shm_recvfrom(shm_socket_t *sokt, void **buf, int *size, int *key,  const struct timespec *timeout,  int flag) {
@@ -423,9 +420,7 @@
 
   shm_msg_t src;
  
-printf ("====== before ======\n");
   rv = sokt->queue->pop(src, timeout, flag);
-printf ("====== after ======\n %d", rv);
 
   if (rv == 0) {
     if(buf != NULL) {
diff --git a/test_net_socket/test_net_mod_socket.cpp b/test_net_socket/test_net_mod_socket.cpp
index 2fcd604..0b7c3cc 100644
--- a/test_net_socket/test_net_mod_socket.cpp
+++ b/test_net_socket/test_net_mod_socket.cpp
@@ -268,7 +268,7 @@
     sprintf(sendbuf, "thread(%d) %d", targ->id, i);
     fprintf(fp, "requst:%s\n", sendbuf);
     // n = net_mod_socket_sendandrecv(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size);
-     n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size, 1000);
+    n = net_mod_socket_sendandrecv_timeout(client, node_arr, node_arr_size, sendbuf, strlen(sendbuf) + 1, &recv_arr, &recv_arr_size, 1000);
     printf("send %d nodes\n", n);
     for(j=0; j < recv_arr_size; j++) {
     	fprintf(fp, "reply: host:%s, port: %d, key:%d, content: %s\n", 
diff --git a/test_socket/bus_test.cpp b/test_socket/bus_test.cpp
index f84ad52..a186d7f 100644
--- a/test_socket/bus_test.cpp
+++ b/test_socket/bus_test.cpp
@@ -23,7 +23,7 @@
 }
 
 
-void *run_recv2(void *skptr) {
+void *run_recv(void *skptr) {
   pthread_detach(pthread_self());
   void *recvbuf;
   int size;
@@ -35,7 +35,8 @@
   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);
@@ -48,10 +49,11 @@
   
 }
 
-void *run_recv(void *skptr) {
+void *run_recv2(void *skptr) {
+  pthread_detach(pthread_self());
   while(true) {
     logger->debug("================run_recv\n");
-    sleep(1);
+    // sleep(1);
   }
 }
 
@@ -77,9 +79,10 @@
   while (true) {
     //printf("Usage: pub <topic> [content] or sub <topic>\n");
     printf("Can I help you? sub, pub, desub or quit %d\n", i++);
-    // sleep(100);
-    scanf("%s", action);
-    
+    printf("client 1\n");
+    // scanf("%s", action);
+    std::cin >> action;
+    printf("client 2\n");
     if(strcmp(action, "sub") == 0) {
       printf("Please input topic!\n");
       scanf("%s", topic);

--
Gitblit v1.8.0