hewei.it před 4 roky
rodič
revize
dbea1679b4
4 změnil soubory, kde provedl 12 přidání a 7 odebrání
  1. 1 1
      event/hloop.h
  2. 4 1
      evpp/Channel.h
  3. 5 3
      http/client/http_client.cpp
  4. 2 2
      http/websocket_parser.c

+ 1 - 1
event/hloop.h

@@ -99,7 +99,7 @@ typedef enum {
 #define HIO_DEFAULT_CONNECT_TIMEOUT     5000    // ms
 #define HIO_DEFAULT_CLOSE_TIMEOUT       60000   // ms
 #define HIO_DEFAULT_KEEPALIVE_TIMEOUT   75000   // ms
-#define HIO_DEFAULT_HEARTBEAT_INTERVAL  30000   // ms
+#define HIO_DEFAULT_HEARTBEAT_INTERVAL  10000   // ms
 
 BEGIN_EXTERN_C
 

+ 4 - 1
evpp/Channel.h

@@ -101,8 +101,11 @@ public:
         return write(str.data(), str.size());
     }
 
-    int close() {
+    int close(bool async = false) {
         if (!isOpened()) return 0;
+        if (async) {
+            return hio_close_async(io_);
+        }
         return hio_close(io_);
     }
 

+ 5 - 3
http/client/http_client.cpp

@@ -438,11 +438,13 @@ const char* http_client_strerror(int errcode) {
 #endif
 
 static int __http_client_send_async(http_client_t* cli, HttpRequestPtr req, HttpResponseCallback resp_cb) {
-    cli->mutex_.lock();
     if (cli->async_client_ == NULL) {
-        cli->async_client_.reset(new hv::AsyncHttpClient);
+        cli->mutex_.lock();
+        if (cli->async_client_ == NULL) {
+            cli->async_client_.reset(new hv::AsyncHttpClient);
+        }
+        cli->mutex_.unlock();
     }
-    cli->mutex_.unlock();
 
     return cli->async_client_->send(req, resp_cb);
 }

+ 2 - 2
http/websocket_parser.c

@@ -158,8 +158,8 @@ size_t websocket_parser_execute(websocket_parser *parser, const websocket_parser
                     p--;
                 }
                 if(!parser->require) {
-                    NOTIFY_CB(frame_end);
                     SET_STATE(s_start);
+                    NOTIFY_CB(frame_end);
                 }
                 break;
             default:
@@ -246,4 +246,4 @@ size_t websocket_build_frame(char * frame, websocket_flags flags, const char mas
     }
 
     return body_offset + data_len;
-}
+}