Merge pull request #273 from JacobBarthelmeh/testing

graceful shutdown with scp interop
pull/277/head
John Safranek 2020-08-26 10:28:23 -07:00 committed by GitHub
commit e5c90b31e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View File

@ -993,20 +993,8 @@ 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;
}
printf("scp file transfer completed\n");
ret = 0;
break;
case WS_SFTP_COMPLETE:

View File

@ -619,6 +619,11 @@ int DoScpSource(WOLFSSH* ssh)
} /* end while */
if (ret == WS_SUCCESS && ssh->scpState == SCP_DONE) {
/* Send SSH_MSG_CHANNEL_CLOSE */
ret = wolfSSH_stream_exit(ssh, 0);
}
return ret;
}
@ -678,6 +683,20 @@ int DoScpRequest(WOLFSSH* ssh)
}
}
if (ret == WS_SUCCESS && ssh->scpState == SCP_DONE) {
byte buf[1];
/* Peer MUST send back a SSH_MSG_CHANNEL_CLOSE unless already
sent*/
ret = wolfSSH_stream_read(ssh, buf, 1);
if (ret != WS_EOF) {
WLOG(WS_LOG_DEBUG, scpState, "Did not receive EOF packet");
}
else {
ret = WS_SUCCESS;
}
}
return ret;
}