]> granicus.if.org Git - esp-idf/commitdiff
ws_client: fixed posting to event loop with websocket timeout
authorDavid Cermak <cermak@espressif.com>
Mon, 26 Aug 2019 06:30:09 +0000 (08:30 +0200)
committerDavid Cermak <cermak@espressif.com>
Mon, 7 Oct 2019 14:34:51 +0000 (16:34 +0200)
Executing event loop `esp_event_loop_run()` with timeout causes delays in receiving events from user code. Fixed by removing the timeout to post synchronously.

closes https://github.com/espressif/esp-idf/issues/3957

components/esp_websocket_client/esp_websocket_client.c

index dc73334190bd02e5610a6919541634978c537da1..c6fe5ce861c791489a191e02964259baa8dbe40c 100644 (file)
@@ -39,7 +39,6 @@ static const char *TAG = "WEBSOCKET_CLIENT";
 #define WEBSOCKET_NETWORK_TIMEOUT_MS    (10*1000)
 #define WEBSOCKET_PING_TIMEOUT_MS       (10*1000)
 #define WEBSOCKET_EVENT_QUEUE_SIZE      (1)
-#define WEBSOCKET_SEND_EVENT_TIMEOUT_MS (1000/portTICK_RATE_MS)
 
 #define ESP_WS_CLIENT_MEM_CHECK(TAG, a, action) if (!(a)) {                                         \
         ESP_LOGE(TAG,"%s:%d (%s): %s", __FILE__, __LINE__, __FUNCTION__, "Memory exhausted");       \
@@ -112,10 +111,10 @@ static esp_err_t esp_websocket_client_dispatch_event(esp_websocket_client_handle
                                  WEBSOCKET_EVENTS, event,
                                  &event_data,
                                  sizeof(esp_websocket_event_data_t),
-                                 WEBSOCKET_SEND_EVENT_TIMEOUT_MS)) != ESP_OK) {
+                                 portMAX_DELAY)) != ESP_OK) {
         return err;
     }
-    return esp_event_loop_run(client->event_handle, WEBSOCKET_SEND_EVENT_TIMEOUT_MS);
+    return esp_event_loop_run(client->event_handle, 0);
 }
 
 static esp_err_t esp_websocket_client_abort_connection(esp_websocket_client_handle_t client)