channesl: Reformat ssh_channel_poll_timeout()

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit fbe115abba)
This commit is contained in:
Andreas Schneider
2019-10-31 11:15:41 +01:00
parent 36bdcb85b3
commit c0e5393927

View File

@@ -3077,7 +3077,8 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr){
* *
* @see ssh_channel_is_eof() * @see ssh_channel_is_eof()
*/ */
int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){ int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr)
{
ssh_session session; ssh_session session;
ssh_buffer stdbuf; ssh_buffer stdbuf;
struct ssh_channel_read_termination_struct ctx; struct ssh_channel_read_termination_struct ctx;
@@ -3096,18 +3097,24 @@ int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){
ctx.buffer = stdbuf; ctx.buffer = stdbuf;
ctx.channel = channel; ctx.channel = channel;
ctx.count = 1; ctx.count = 1;
rc = ssh_handle_packets_termination(channel->session, timeout, rc = ssh_handle_packets_termination(channel->session,
ssh_channel_read_termination, &ctx); timeout,
if(rc ==SSH_ERROR || session->session_state == SSH_SESSION_STATE_ERROR){ ssh_channel_read_termination,
&ctx);
if (rc == SSH_ERROR ||
session->session_state == SSH_SESSION_STATE_ERROR) {
rc = SSH_ERROR; rc = SSH_ERROR;
goto end; goto out;
} }
rc = ssh_buffer_get_len(stdbuf); rc = ssh_buffer_get_len(stdbuf);
if(rc > 0) if(rc > 0) {
goto end; goto out;
if (channel->remote_eof) }
if (channel->remote_eof) {
rc = SSH_EOF; rc = SSH_EOF;
end: }
out:
return rc; return rc;
} }