diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-05-03 17:54:16 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-05-03 17:54:16 +0000 |
commit | e7fc9ab369aa46a9335aef2089b702306fd40645 (patch) | |
tree | 42ef870a800df7b384f6cc04e8c694b242067374 | |
parent | 2b705786c0a4be4429521ab53dc14fe82959cbc4 (diff) | |
download | libssh-e7fc9ab369aa46a9335aef2089b702306fd40645.tar.gz libssh-e7fc9ab369aa46a9335aef2089b702306fd40645.tar.xz libssh-e7fc9ab369aa46a9335aef2089b702306fd40645.zip |
Improve channel_rcv_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@680 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r-- | libssh/channels.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index a169d53..79e162a 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -425,31 +425,43 @@ static void channel_rcv_eof(SSH_SESSION *session) { leave_function(); } -static void channel_rcv_close(SSH_SESSION *session){ - CHANNEL *channel; - enter_function(); - channel=channel_from_msg(session); - if(!channel){ - ssh_log(session, SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session)); - leave_function(); - return; - } - ssh_log(session, SSH_LOG_PACKET, - "Received close on channel (%d:%d)", - channel->local_channel, - channel->remote_channel); - if((channel->stdout_buffer && buffer_get_rest_len(channel->stdout_buffer)>0) - || (channel->stderr_buffer && buffer_get_rest_len(channel->stderr_buffer)>0)) - channel->delayed_close=1; - else - channel->open=0; - if(!channel->remote_eof) - ssh_log(session, SSH_LOG_PACKET, - "Remote host not polite enough to send an eof before close"); - channel->remote_eof=1; - /* the remote eof doesn't break things if there was still data into read - * buffer because the eof is ignored until the buffer is empty. */ +static void channel_rcv_close(SSH_SESSION *session) { + CHANNEL *channel; + + enter_function(); + + channel = channel_from_msg(session); + if (channel == NULL) { + ssh_log(session, SSH_LOG_FUNCTIONS, ssh_get_error(session)); leave_function(); + return; + } + + ssh_log(session, SSH_LOG_PACKET, + "Received close on channel (%d:%d)", + channel->local_channel, + channel->remote_channel); + + if ((channel->stdout_buffer && + buffer_get_rest_len(channel->stdout_buffer) > 0) || + (channel->stderr_buffer && + buffer_get_rest_len(channel->stderr_buffer) > 0)) { + channel->delayed_close = 1; + } else { + channel->open = 0; + } + + if (channel->remote_eof == 0) { + ssh_log(session, SSH_LOG_PACKET, + "Remote host not polite enough to send an eof before close"); + } + channel->remote_eof = 1; + /* + * The remote eof doesn't break things if there was still data into read + * buffer because the eof is ignored until the buffer is empty. + */ + + leave_function(); } static void channel_rcv_request(SSH_SESSION *session){ |