aboutsummaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-10-31 11:15:41 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-12-09 16:08:03 +0100
commitfbe115abba26d8c797c79f4418b92101f8bd13a6 (patch)
treea3d54ee8a6ee0ef3dfb07c7e4008cdc8cd1ba94e /src/channels.c
parent66c4857c4a7a5b59b359681b7b15c1b8745d3a6e (diff)
downloadlibssh-fbe115abba26d8c797c79f4418b92101f8bd13a6.tar.gz
libssh-fbe115abba26d8c797c79f4418b92101f8bd13a6.tar.xz
libssh-fbe115abba26d8c797c79f4418b92101f8bd13a6.zip
channesl: Reformat ssh_channel_poll_timeout()
Fixes T188 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/src/channels.c b/src/channels.c
index 19eabef7..c97e94d3 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -3077,38 +3077,45 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr){
*
* @see ssh_channel_is_eof()
*/
-int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr){
- ssh_session session;
- ssh_buffer stdbuf;
- struct ssh_channel_read_termination_struct ctx;
- int rc;
+int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr)
+{
+ ssh_session session;
+ ssh_buffer stdbuf;
+ struct ssh_channel_read_termination_struct ctx;
+ int rc;
- if(channel == NULL) {
- return SSH_ERROR;
- }
+ if(channel == NULL) {
+ return SSH_ERROR;
+ }
- session = channel->session;
- stdbuf = channel->stdout_buffer;
+ session = channel->session;
+ stdbuf = channel->stdout_buffer;
- if (is_stderr) {
- stdbuf = channel->stderr_buffer;
- }
- ctx.buffer = stdbuf;
- ctx.channel = channel;
- ctx.count = 1;
- rc = ssh_handle_packets_termination(channel->session, timeout,
- ssh_channel_read_termination, &ctx);
- if(rc ==SSH_ERROR || session->session_state == SSH_SESSION_STATE_ERROR){
- rc = SSH_ERROR;
- goto end;
- }
- rc = ssh_buffer_get_len(stdbuf);
- if(rc > 0)
- goto end;
- if (channel->remote_eof)
- rc = SSH_EOF;
-end:
- return rc;
+ if (is_stderr) {
+ stdbuf = channel->stderr_buffer;
+ }
+ ctx.buffer = stdbuf;
+ ctx.channel = channel;
+ ctx.count = 1;
+ rc = ssh_handle_packets_termination(channel->session,
+ timeout,
+ ssh_channel_read_termination,
+ &ctx);
+ if (rc == SSH_ERROR ||
+ session->session_state == SSH_SESSION_STATE_ERROR) {
+ rc = SSH_ERROR;
+ goto out;
+ }
+ rc = ssh_buffer_get_len(stdbuf);
+ if(rc > 0) {
+ goto out;
+ }
+ if (channel->remote_eof) {
+ rc = SSH_EOF;
+ }
+
+out:
+ return rc;
}
/**