Skip to content

Commit 17a7169

Browse files
committed
fix(esp-tls): clean up is_tls flag
1 parent ab14938 commit 17a7169

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

components/esp-tls/esp_tls.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,15 +468,12 @@ static int esp_tls_low_level_conn(const char *hostname, int hostlen, int port, c
468468
switch (tls->conn_state) {
469469
case ESP_TLS_INIT:
470470
tls->sockfd = -1;
471-
if (cfg != NULL && cfg->is_plain_tcp == false) {
472-
_esp_tls_net_init(tls);
473-
tls->is_tls = true;
474-
}
471+
_esp_tls_net_init(tls);
475472
if ((esp_ret = tcp_connect(hostname, hostlen, port, cfg, tls->error_handle, &tls->sockfd)) != ESP_OK) {
476473
ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_ESP, esp_ret);
477474
return -1;
478475
}
479-
if (tls->is_tls == false) {
476+
if (cfg && cfg->is_plain_tcp) {
480477
tls->read = tcp_read;
481478
tls->write = tcp_write;
482479
ESP_LOGD(TAG, "non-tls connection established");

components/esp-tls/esp_tls_mbedtls.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,10 @@ void esp_mbedtls_conn_delete(esp_tls_t *tls)
456456
{
457457
if (tls != NULL) {
458458
esp_mbedtls_cleanup(tls);
459-
if (tls->is_tls) {
460-
if (tls->server_fd.fd != -1) {
461-
mbedtls_net_free(&tls->server_fd);
462-
/* Socket is already closed by `mbedtls_net_free` and hence also change assignment of its copy to an invalid value */
463-
tls->sockfd = -1;
464-
}
459+
if (tls->server_fd.fd != -1) {
460+
mbedtls_net_free(&tls->server_fd);
461+
/* Socket is already closed by `mbedtls_net_free` and hence also change assignment of its copy to an invalid value */
462+
tls->sockfd = -1;
465463
}
466464
}
467465
}

components/esp-tls/private_include/esp_tls_private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ struct esp_tls {
9191

9292
fd_set wset; /*!< write file descriptors */
9393

94-
bool is_tls; /*!< indicates connection type (TLS or NON-TLS) */
95-
9694
esp_tls_role_t role; /*!< esp-tls role
9795
- ESP_TLS_CLIENT
9896
- ESP_TLS_SERVER */

0 commit comments

Comments
 (0)