From: Jitin George Date: Fri, 13 Apr 2018 10:29:35 +0000 (+0530) Subject: esp-tls: Fix connection failure when esp-tls config is empty X-Git-Tag: v3.1-beta1~247^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d0445103bc429938f99472ba8f8cea7d66e8caf;p=esp-idf esp-tls: Fix connection failure when esp-tls config is empty --- diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index d84cf77bf9..5309d7796a 100644 --- a/components/esp-tls/esp_tls.c +++ b/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;