Selaa lähdekoodia

fixbug: crash when enable_reconnect=true

hewei.it 4 vuotta sitten
vanhempi
commit
156f8d0420
2 muutettua tiedostoa jossa 2 lisäystä ja 0 poistoa
  1. 1 0
      evpp/EventLoop.h
  2. 1 0
      evpp/TcpClient.h

+ 1 - 0
evpp/EventLoop.h

@@ -75,6 +75,7 @@ public:
 
     // Timer interfaces: setTimer, killTimer, resetTimer
     TimerID setTimer(int timeout_ms, TimerCallback cb, int repeat = INFINITE) {
+        if (loop_ == NULL) return INVALID_TIMER_ID;
         htimer_t* htimer = htimer_add(loop_, onTimer, timeout_ms, repeat);
 
         Timer timer(htimer, cb, repeat);

+ 1 - 0
evpp/TcpClient.h

@@ -149,6 +149,7 @@ public:
         loop_thread.start(wait_threads_started, std::bind(&TcpClientTmpl::startConnect, this));
     }
     void stop(bool wait_threads_stopped = true) {
+        enable_reconnect = false;
         loop_thread.stop(wait_threads_stopped);
     }