continue to cleanup on fail case and use WLOG for debug messages

pull/732/head
JacobBarthelmeh 2024-08-05 13:23:04 -06:00
parent 40aabc253b
commit fdecd765b9
1 changed files with 14 additions and 5 deletions

View File

@ -1120,15 +1120,18 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args)
if (ret != WS_SOCKET_ERROR_E if (ret != WS_SOCKET_ERROR_E
&& wolfSSH_get_error(ssh) != WS_SOCKET_ERROR_E) { && wolfSSH_get_error(ssh) != WS_SOCKET_ERROR_E) {
if (ret != WS_SUCCESS) { if (ret != WS_SUCCESS) {
err_sys("Sending the shutdown messages failed."); WLOG(WS_LOG_DEBUG, "Sending the shutdown messages failed.");
}
else {
ret = wolfSSH_worker(ssh, NULL);
} }
ret = wolfSSH_worker(ssh, NULL);
if (ret == WS_CHANNEL_CLOSED) { if (ret == WS_CHANNEL_CLOSED) {
/* Shutting down, channel closing isn't a fail. */ /* Shutting down, channel closing isn't a fail. */
ret = WS_SUCCESS; ret = WS_SUCCESS;
} }
else if (ret != WS_SUCCESS) { else if (ret != WS_SUCCESS) {
err_sys("Failed to listen for close messages from the peer."); WLOG(WS_LOG_DEBUG,
"Failed to listen for close messages from the peer.");
} }
} }
WCLOSESOCKET(sockFd); WCLOSESOCKET(sockFd);
@ -1139,8 +1142,14 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args)
wolfSSH_free(ssh); wolfSSH_free(ssh);
wolfSSH_CTX_free(ctx); wolfSSH_CTX_free(ctx);
if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E) if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E) {
err_sys("Closing client stream failed"); WLOG(WS_LOG_DEBUG, "Closing client stream failed");
#if defined(WOLFSSH_TERM) || defined(WOLFSSH_SHELL)
/* override return value, do not want to return success if connection
* close failed */
((func_args*)args)->return_code = 1;
#endif
}
ClientFreeBuffers(); ClientFreeBuffers();
#if !defined(WOLFSSH_NO_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) #if !defined(WOLFSSH_NO_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)