Skip to content

Commit fdecd76

Browse files
continue to cleanup on fail case and use WLOG for debug messages
1 parent 40aabc2 commit fdecd76

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

apps/wolfssh/wolfssh.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,18 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args)
11201120
if (ret != WS_SOCKET_ERROR_E
11211121
&& wolfSSH_get_error(ssh) != WS_SOCKET_ERROR_E) {
11221122
if (ret != WS_SUCCESS) {
1123-
err_sys("Sending the shutdown messages failed.");
1123+
WLOG(WS_LOG_DEBUG, "Sending the shutdown messages failed.");
1124+
}
1125+
else {
1126+
ret = wolfSSH_worker(ssh, NULL);
11241127
}
1125-
ret = wolfSSH_worker(ssh, NULL);
11261128
if (ret == WS_CHANNEL_CLOSED) {
11271129
/* Shutting down, channel closing isn't a fail. */
11281130
ret = WS_SUCCESS;
11291131
}
11301132
else if (ret != WS_SUCCESS) {
1131-
err_sys("Failed to listen for close messages from the peer.");
1133+
WLOG(WS_LOG_DEBUG,
1134+
"Failed to listen for close messages from the peer.");
11321135
}
11331136
}
11341137
WCLOSESOCKET(sockFd);
@@ -1139,8 +1142,14 @@ static THREAD_RETURN WOLFSSH_THREAD wolfSSH_Client(void* args)
11391142

11401143
wolfSSH_free(ssh);
11411144
wolfSSH_CTX_free(ctx);
1142-
if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E)
1143-
err_sys("Closing client stream failed");
1145+
if (ret != WS_SUCCESS && ret != WS_SOCKET_ERROR_E) {
1146+
WLOG(WS_LOG_DEBUG, "Closing client stream failed");
1147+
#if defined(WOLFSSH_TERM) || defined(WOLFSSH_SHELL)
1148+
/* override return value, do not want to return success if connection
1149+
* close failed */
1150+
((func_args*)args)->return_code = 1;
1151+
#endif
1152+
}
11441153

11451154
ClientFreeBuffers();
11461155
#if !defined(WOLFSSH_NO_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS)

0 commit comments

Comments
 (0)