graceful shutdown with scp interop

pull/273/head
Jacob Barthelmeh 2020-08-19 10:55:45 -06:00
parent 95ebbe9e59
commit 03fac18efd
2 changed files with 21 additions and 14 deletions

View File

@ -792,20 +792,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;
}