channel: Reformat ssh_channel_close()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
e4e51ccc13
Коммит
0ba10870d1
@ -1136,52 +1136,54 @@ error:
|
|||||||
* @see ssh_channel_free()
|
* @see ssh_channel_free()
|
||||||
* @see ssh_channel_is_eof()
|
* @see ssh_channel_is_eof()
|
||||||
*/
|
*/
|
||||||
int ssh_channel_close(ssh_channel channel){
|
int ssh_channel_close(ssh_channel channel)
|
||||||
ssh_session session;
|
{
|
||||||
int rc = 0;
|
ssh_session session;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if(channel == NULL) {
|
if(channel == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
session = channel->session;
|
session = channel->session;
|
||||||
|
|
||||||
if (channel->local_eof == 0) {
|
if (channel->local_eof == 0) {
|
||||||
rc = ssh_channel_send_eof(channel);
|
rc = ssh_channel_send_eof(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ssh_buffer_pack(session->out_buffer,
|
||||||
|
"bd",
|
||||||
|
SSH2_MSG_CHANNEL_CLOSE,
|
||||||
|
channel->remote_channel);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
ssh_set_error_oom(session);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ssh_packet_send(session);
|
||||||
|
SSH_LOG(SSH_LOG_PACKET,
|
||||||
|
"Sent a close on client channel (%d:%d)",
|
||||||
|
channel->local_channel,
|
||||||
|
channel->remote_channel);
|
||||||
|
|
||||||
|
if (rc == SSH_OK) {
|
||||||
|
channel->state = SSH_CHANNEL_STATE_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ssh_channel_flush(channel);
|
||||||
|
if(rc == SSH_ERROR) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (rc != SSH_OK) {
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
|
||||||
|
|
||||||
rc = ssh_buffer_pack(session->out_buffer,
|
|
||||||
"bd",
|
|
||||||
SSH2_MSG_CHANNEL_CLOSE,
|
|
||||||
channel->remote_channel);
|
|
||||||
if (rc != SSH_OK) {
|
|
||||||
ssh_set_error_oom(session);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ssh_packet_send(session);
|
|
||||||
SSH_LOG(SSH_LOG_PACKET,
|
|
||||||
"Sent a close on client channel (%d:%d)",
|
|
||||||
channel->local_channel,
|
|
||||||
channel->remote_channel);
|
|
||||||
|
|
||||||
if(rc == SSH_OK) {
|
|
||||||
channel->state=SSH_CHANNEL_STATE_CLOSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ssh_channel_flush(channel);
|
|
||||||
if(rc == SSH_ERROR)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
error:
|
error:
|
||||||
ssh_buffer_reinit(session->out_buffer);
|
ssh_buffer_reinit(session->out_buffer);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this termination function waits for a window growing condition */
|
/* this termination function waits for a window growing condition */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user