Skip to content

Commit

Permalink
fix(mbedtls): Fix disconnect callback function never be called
Browse files Browse the repository at this point in the history
Fix disconnect callback function is not called when error number is -7880

internal gitlab: d2bca18e
  • Loading branch information
wujiangang committed Dec 5, 2017
1 parent fe32f7f commit cf608e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ phy:
gitlab:
driver : 68fc7b06
lwip : 798515fd
mbedtls : fd271f4e
mbedtls : bac3b3e5
Binary file modified lib/libmbedtls.a
Binary file not shown.
18 changes: 13 additions & 5 deletions third_party/mbedtls/app/espconn_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ static void mbedtls_fail_info(espconn_msg *pinfo, int ret)
} else {
os_printf("client's data invalid protocol\n");
}
mbedtls_ssl_close_notify(&TLSmsg->ssl);
if(ret != MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY){
mbedtls_ssl_close_notify(&TLSmsg->ssl);
}
} else{
if (pinfo->preverse != NULL) {
os_printf("server handshake failed!\n");
Expand Down Expand Up @@ -830,7 +832,10 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)
if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == 0){
ret = ESPCONN_OK;
break;
} else{
} else if(ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY){
ret = ESPCONN_OK;
mbedtls_ssl_close_notify(&TLSmsg->ssl);
}else{
break;
}
}
Expand Down Expand Up @@ -931,9 +936,12 @@ int __attribute__((weak)) mbedtls_parse_internal(int socket, sint8 error)

exit:
if (ret != ESPCONN_OK){
mbedtls_fail_info(Threadmsg, ret);
ets_post(lwIPThreadPrio, NETCONN_EVENT_CLOSE,(uint32)Threadmsg);
}
mbedtls_fail_info(Threadmsg, ret);
if(ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY){
Threadmsg->hs_status = ESPCONN_OK;
ets_post(lwIPThreadPrio, NETCONN_EVENT_CLOSE,(uint32)Threadmsg);
}
}
return ret;
}

Expand Down

0 comments on commit cf608e9

Please sign in to comment.