Merge pull request #241 from JacobBarthelmeh/scp

exit channel in echoserver before sending disconnect
pull/248/head
John Safranek 2020-02-27 19:18:30 -08:00 committed by GitHub
commit 380a53554b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -401,8 +401,20 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs)
switch (ret) {
case WS_SCP_COMPLETE:
{
byte buf[1];
printf("scp file transfer completed\n");
if (wolfSSH_stream_exit(threadCtx->ssh, 0) != WS_SUCCESS) {
fprintf(stderr, "Error with SSH stream exit.\n");
}
/* Peer MUST send back a SSH_MSG_CHANNEL_CLOSE unless already
* sent*/
ret = wolfSSH_stream_read(threadCtx->ssh, buf, 1);
if (ret != WS_EOF) {
fprintf(stderr, "Was expecting EOF\n");
}
ret = 0;
}
break;
case WS_SFTP_COMPLETE:

View File

@ -873,6 +873,11 @@ int wolfSSH_shutdown(WOLFSSH* ssh)
if (ret == WS_SUCCESS)
ret = SendDisconnect(ssh, WOLFSSH_DISCONNECT_BY_APPLICATION);
if (ssh != NULL && ssh->channelList == NULL) {
WLOG(WS_LOG_DEBUG, "channel list was already removed");
ret = WS_SUCCESS;
}
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_shutdown(), ret = %d", ret);
return ret;
}