mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 10:26:47 +09:00
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:
@@ -3077,38 +3077,45 @@ 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_buffer stdbuf;
|
ssh_session session;
|
||||||
struct ssh_channel_read_termination_struct ctx;
|
ssh_buffer stdbuf;
|
||||||
int rc;
|
struct ssh_channel_read_termination_struct ctx;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if(channel == NULL) {
|
if(channel == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
session = channel->session;
|
session = channel->session;
|
||||||
stdbuf = channel->stdout_buffer;
|
stdbuf = channel->stdout_buffer;
|
||||||
|
|
||||||
if (is_stderr) {
|
if (is_stderr) {
|
||||||
stdbuf = channel->stderr_buffer;
|
stdbuf = channel->stderr_buffer;
|
||||||
}
|
}
|
||||||
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,
|
||||||
rc = SSH_ERROR;
|
&ctx);
|
||||||
goto end;
|
if (rc == SSH_ERROR ||
|
||||||
}
|
session->session_state == SSH_SESSION_STATE_ERROR) {
|
||||||
rc = ssh_buffer_get_len(stdbuf);
|
rc = SSH_ERROR;
|
||||||
if(rc > 0)
|
goto out;
|
||||||
goto end;
|
}
|
||||||
if (channel->remote_eof)
|
rc = ssh_buffer_get_len(stdbuf);
|
||||||
rc = SSH_EOF;
|
if(rc > 0) {
|
||||||
end:
|
goto out;
|
||||||
return rc;
|
}
|
||||||
|
if (channel->remote_eof) {
|
||||||
|
rc = SSH_EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user