Ver Fonte

Updated coding style and added error logs

Harshit Malpani há 3 anos atrás
pai
commit
2c56c6cad8

+ 2 - 1
components/esp_local_ctrl/src/esp_local_ctrl_transport_httpd.c

@@ -77,8 +77,9 @@ static void stop_httpd_transport(protocomm_t *pc)
 {
     mdns_service_remove("_esp_local_ctrl", "_tcp");
     protocomm_httpd_stop(pc);
-    if (httpd_ssl_stop(server_handle) == ESP_OK)
+    if (httpd_ssl_stop(server_handle) == ESP_OK) {
         server_handle = NULL;
+    }
 }
 
 static esp_err_t copy_httpd_config(esp_local_ctrl_transport_config_t *dest_config, const esp_local_ctrl_transport_config_t *src_config)

+ 3 - 1
components/protocomm/src/transports/protocomm_httpd.c

@@ -296,8 +296,10 @@ esp_err_t protocomm_httpd_stop(protocomm_t *pc)
         if (!pc_ext_httpd_handle_provided) {
             httpd_handle_t *server_handle = (httpd_handle_t *) pc_httpd->priv;
             esp_err_t ret = httpd_stop(*server_handle);
-            if (ret != ESP_OK)
+            if (ret != ESP_OK) {
+                ESP_LOGE(TAG, "Failed to stop http server");
                 return ret;
+            }
             free(server_handle);
         } else {
             pc_ext_httpd_handle_provided = false;

+ 4 - 1
examples/protocols/http_server/persistent_sockets/main/main.c

@@ -195,8 +195,11 @@ static void disconnect_handler(void* arg, esp_event_base_t event_base,
     httpd_handle_t* server = (httpd_handle_t*) arg;
     if (*server) {
         ESP_LOGI(TAG, "Stopping webserver");
-        if (stop_webserver(*server) == ESP_OK)
+        if (stop_webserver(*server) == ESP_OK) {
             *server = NULL;
+        } else {
+            ESP_LOGE(TAG, "Failed to stop http server");
+        }
     }
 }
 

+ 4 - 1
examples/protocols/http_server/simple/main/main.c

@@ -374,8 +374,11 @@ static void disconnect_handler(void* arg, esp_event_base_t event_base,
     httpd_handle_t* server = (httpd_handle_t*) arg;
     if (*server) {
         ESP_LOGI(TAG, "Stopping webserver");
-        if (stop_webserver(*server) == ESP_OK)
+        if (stop_webserver(*server) == ESP_OK) {
             *server = NULL;
+        } else {
+            ESP_LOGE(TAG, "Failed to stop http server");
+        }
     }
 }
 

+ 4 - 1
examples/protocols/http_server/ws_echo_server/main/ws_echo_server.c

@@ -152,8 +152,11 @@ static void disconnect_handler(void* arg, esp_event_base_t event_base,
     httpd_handle_t* server = (httpd_handle_t*) arg;
     if (*server) {
         ESP_LOGI(TAG, "Stopping webserver");
-        if (stop_webserver(*server) == ESP_OK)
+        if (stop_webserver(*server) == ESP_OK) {
             *server = NULL;
+        } else {
+            ESP_LOGE(TAG, "Failed to stop http server");
+        }
     }
 }
 

+ 4 - 1
examples/protocols/https_server/simple/main/main.c

@@ -150,8 +150,11 @@ static void disconnect_handler(void* arg, esp_event_base_t event_base,
 {
     httpd_handle_t* server = (httpd_handle_t*) arg;
     if (*server) {
-        if (stop_webserver(*server) == ESP_OK)
+        if (stop_webserver(*server) == ESP_OK) {
             *server = NULL;
+        } else {
+            ESP_LOGE(TAG, "Failed to stop https server");
+        }
     }
 }
 

+ 4 - 1
examples/protocols/https_server/wss_server/main/wss_server_example.c

@@ -219,8 +219,11 @@ static void disconnect_handler(void* arg, esp_event_base_t event_base,
 {
     httpd_handle_t* server = (httpd_handle_t*) arg;
     if (*server) {
-        if (stop_wss_echo_server(*server) == ESP_OK)
+        if (stop_wss_echo_server(*server) == ESP_OK) {
             *server = NULL;
+        } else {
+            ESP_LOGE(TAG, "Failed to stop https server");
+        }
     }
 }