Skip to content

Commit

Permalink
Merge pull request #14 from aozima/aozima_net_dev
Browse files Browse the repository at this point in the history
修复mqtt断开连接时,会重复关闭fd造成程序崩溃的问题。
  • Loading branch information
armink authored Apr 27, 2019
2 parents 4a0b5ab + bd5ac30 commit 5872b33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ports/ssl/mbedtls/HAL_TLS_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static int _TLSConnectNetwork(TLSDataParams_t *pTlsData, const char *addr, const
}
#else
if (0 != (ret = mbedtls_net_connect(&(pTlsData->fd), addr, port, MBEDTLS_NET_PROTO_TCP))) {
pTlsData->fd.fd = -1;
SSL_LOG(" failed ! net_connect returned -0x%04x", -ret);
return ret;
}
Expand Down Expand Up @@ -498,7 +499,12 @@ static int _network_ssl_write(TLSDataParams_t *pTlsData, const char *buffer, int
static void _network_ssl_disconnect(TLSDataParams_t *pTlsData)
{
mbedtls_ssl_close_notify(&(pTlsData->ssl));
mbedtls_net_free(&(pTlsData->fd));

if((pTlsData->fd.fd) >= 0)
{
mbedtls_net_free(&(pTlsData->fd));
}

#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_x509_crt_free(&(pTlsData->cacertl));
if ((pTlsData->pkey).pk_info != NULL) {
Expand Down

0 comments on commit 5872b33

Please sign in to comment.