Sfoglia il codice sorgente

esp-tls: Fix connection failure when esp-tls config is empty

Jitin George 7 anni fa
parent
commit
0d0445103b
1 ha cambiato i file con 6 aggiunte e 7 eliminazioni
  1. 6 7
      components/esp-tls/esp_tls.c

+ 6 - 7
components/esp-tls/esp_tls.c

@@ -277,13 +277,12 @@ esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const e
             esp_tls_conn_delete(tls);
             return NULL;
         }
-	tls->read = tls_read;
-	tls->write = tls_write;
-    }
-
-    if (cfg->non_block == true) {
-        int flags = fcntl(tls->sockfd, F_GETFL, 0);
-        fcntl(tls->sockfd, F_SETFL, flags | O_NONBLOCK);    
+    	tls->read = tls_read;
+    	tls->write = tls_write;
+        if (cfg->non_block == true) {
+            int flags = fcntl(tls->sockfd, F_GETFL, 0);
+            fcntl(tls->sockfd, F_SETFL, flags | O_NONBLOCK);
+        }
     }
 
     return tls;