diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-05-03 18:35:36 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-05-03 18:35:36 +0000 |
commit | 17c146391c51f5dc2670d72489d72f9ae364f106 (patch) | |
tree | bba31e972b209d183f43159765778d451a81b879 | |
parent | b27e5b67856993be048021ad8e71350a3113f31e (diff) | |
download | libssh-17c146391c51f5dc2670d72489d72f9ae364f106.tar.gz libssh-17c146391c51f5dc2670d72489d72f9ae364f106.tar.xz libssh-17c146391c51f5dc2670d72489d72f9ae364f106.zip |
Improve channel_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@688 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r-- | libssh/channels.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/libssh/channels.c b/libssh/channels.c index c1d6511e..72219e55 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -794,14 +794,19 @@ error: return rc; } -/** It sends an end of file and then closes the channel. You won't be able +/** + * @brief Close a channel. + * + * This sends an end of file and then closes the channel. You won't be able * to recover any data the server was going to send or was in buffers. - * \brief close a channel - * \param channel channel - * \return SSH_ERROR on error\n - * SSH_SUCCESS on success - * \see channel_free() - * \see channel_eof() + * + * @param channel The channel to close. + * + * @return SSH_SUCCESS on success\n + * SSH_ERROR on error + * + * @see channel_free() + * @see channel_eof() */ int channel_close(CHANNEL *channel){ SSH_SESSION *session = channel->session; @@ -809,19 +814,17 @@ int channel_close(CHANNEL *channel){ enter_function(); - if (!channel->local_eof) { + if (channel->local_eof == 0) { rc = channel_send_eof(channel); } - if (rc) { + if (rc != SSH_OK) { leave_function(); return rc; } - if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_CLOSE) < 0) { - goto error; - } - if (buffer_add_u32(session->out_buffer, htonl(channel->remote_channel)) < 0) { + if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_CLOSE) < 0 || + buffer_add_u32(session->out_buffer, htonl(channel->remote_channel)) < 0) { goto error; } @@ -830,6 +833,7 @@ int channel_close(CHANNEL *channel){ "Sent a close on client channel (%d:%d)", channel->local_channel, channel->remote_channel); + if(rc == SSH_OK) { channel->open = 0; } |