]> granicus.if.org Git - esp-idf/commitdiff
esp-tls: Fix connection failure when esp-tls config is empty
authorJitin George <jitin@espressif.com>
Fri, 13 Apr 2018 10:29:35 +0000 (15:59 +0530)
committerJitin George <jitin@espressif.com>
Fri, 13 Apr 2018 11:28:19 +0000 (16:58 +0530)
components/esp-tls/esp_tls.c

index d84cf77bf93166934a07ffe61a1023bd6c4edddd..5309d7796a50fe287d6b113cae4d6ead4379dbce 100644 (file)
@@ -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;