Improve channel_close().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@688 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-05-03 18:35:36 +00:00
parent b27e5b6785
commit 17c146391c

View File

@@ -794,14 +794,19 @@ error:
return rc; 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. * to recover any data the server was going to send or was in buffers.
* \brief close a channel *
* \param channel channel * @param channel The channel to close.
* \return SSH_ERROR on error\n *
* SSH_SUCCESS on success * @return SSH_SUCCESS on success\n
* \see channel_free() * SSH_ERROR on error
* \see channel_eof() *
* @see channel_free()
* @see channel_eof()
*/ */
int channel_close(CHANNEL *channel){ int channel_close(CHANNEL *channel){
SSH_SESSION *session = channel->session; SSH_SESSION *session = channel->session;
@@ -809,19 +814,17 @@ int channel_close(CHANNEL *channel){
enter_function(); enter_function();
if (!channel->local_eof) { if (channel->local_eof == 0) {
rc = channel_send_eof(channel); rc = channel_send_eof(channel);
} }
if (rc) { if (rc != SSH_OK) {
leave_function(); leave_function();
return rc; return rc;
} }
if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_CLOSE) < 0) { if (buffer_add_u8(session->out_buffer, SSH2_MSG_CHANNEL_CLOSE) < 0 ||
goto error; buffer_add_u32(session->out_buffer, htonl(channel->remote_channel)) < 0) {
}
if (buffer_add_u32(session->out_buffer, htonl(channel->remote_channel)) < 0) {
goto error; goto error;
} }
@@ -830,6 +833,7 @@ int channel_close(CHANNEL *channel){
"Sent a close on client channel (%d:%d)", "Sent a close on client channel (%d:%d)",
channel->local_channel, channel->local_channel,
channel->remote_channel); channel->remote_channel);
if(rc == SSH_OK) { if(rc == SSH_OK) {
channel->open = 0; channel->open = 0;
} }