فهرست منبع

valgrind check

ithewei 4 سال پیش
والد
کامیت
516a9bc849
6فایلهای تغییر یافته به همراه19 افزوده شده و 5 حذف شده
  1. 4 1
      evpp/Channel.h
  2. 1 0
      evpp/EventLoopThreadPool_test.cpp
  3. 3 1
      evpp/TcpClient_test.cpp
  4. 5 1
      evpp/TcpServer_test.cpp
  5. 3 1
      evpp/UdpClient_test.cpp
  6. 3 1
      evpp/UdpServer_test.cpp

+ 4 - 1
evpp/Channel.h

@@ -19,11 +19,15 @@ public:
         fd_ = -1;
         id_ = 0;
         ctx_ = NULL;
+        status = CLOSED;
         if (io) {
             fd_ = hio_fd(io);
             id_ = hio_id(io);
             ctx_ = hio_context(io);
             hio_set_context(io, this);
+            if (hio_is_opened(io)) {
+                status = OPENED;
+            }
             if (hio_getcb_read(io) == NULL) {
                 hio_setcb_read(io_, on_read);
             }
@@ -34,7 +38,6 @@ public:
                 hio_setcb_close(io_, on_close);
             }
         }
-        status = isOpened() ? OPENED : CLOSED;
     }
 
     virtual ~Channel() {

+ 1 - 0
evpp/EventLoopThreadPool_test.cpp

@@ -17,6 +17,7 @@ static void onTimer(TimerID timerID, int n) {
 
 int main(int argc, char* argv[]) {
     HV_MEMCHECK;
+    hlog_set_level(LOG_LEVEL_DEBUG);
 
     printf("main tid=%ld\n", hv_gettid());
 

+ 3 - 1
evpp/TcpClient_test.cpp

@@ -53,6 +53,8 @@ int main(int argc, char* argv[]) {
     cli.setReconnect(&reconn);
     cli.start();
 
-    while (1) hv_sleep(1);
+    // press Enter to stop
+    while (getchar() != '\n');
+
     return 0;
 }

+ 5 - 1
evpp/TcpServer_test.cpp

@@ -16,6 +16,8 @@ int main(int argc, char* argv[]) {
     }
     int port = atoi(argv[1]);
 
+    hlog_set_level(LOG_LEVEL_DEBUG);
+
     TcpServer srv;
     int listenfd = srv.createsocket(port);
     if (listenfd < 0) {
@@ -38,6 +40,8 @@ int main(int argc, char* argv[]) {
     srv.setThreadNum(4);
     srv.start();
 
-    while (1) hv_sleep(1);
+    // press Enter to stop
+    while (getchar() != '\n');
+
     return 0;
 }

+ 3 - 1
evpp/UdpClient_test.cpp

@@ -36,6 +36,8 @@ int main(int argc, char* argv[]) {
         cli.sendto(str);
     });
 
-    while (1) hv_sleep(1);
+    // press Enter to stop
+    while (getchar() != '\n');
+
     return 0;
 }

+ 3 - 1
evpp/UdpServer_test.cpp

@@ -29,6 +29,8 @@ int main(int argc, char* argv[]) {
     };
     srv.start();
 
-    while (1) hv_sleep(1);
+    // press Enter to stop
+    while (getchar() != '\n');
+
     return 0;
 }