mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
channels: Send close if we received a remote close
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit c3067f8e73)
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
@@ -1008,8 +1009,29 @@ void ssh_channel_free(ssh_channel channel)
|
||||
}
|
||||
|
||||
session = channel->session;
|
||||
if (session->alive && channel->state == SSH_CHANNEL_STATE_OPEN) {
|
||||
ssh_channel_close(channel);
|
||||
if (session->alive) {
|
||||
bool send_close = false;
|
||||
|
||||
switch (channel->state) {
|
||||
case SSH_CHANNEL_STATE_OPEN:
|
||||
send_close = true;
|
||||
break;
|
||||
case SSH_CHANNEL_STATE_CLOSED:
|
||||
if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) {
|
||||
send_close = true;
|
||||
}
|
||||
if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_LOCAL) {
|
||||
send_close = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
send_close = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (send_close) {
|
||||
ssh_channel_close(channel);
|
||||
}
|
||||
}
|
||||
channel->flags |= SSH_CHANNEL_FLAG_FREED_LOCAL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user