修正:SSH会话结束后,未更新结束状态到数据库,导致WEB页面始终显示会话未结束。

dev
Apex Liu 2020-11-07 02:13:37 +08:00
parent d8c6bd0c84
commit a50b540b95
4 changed files with 14 additions and 16 deletions

View File

@ -141,13 +141,14 @@ class BuilderLinux(BuilderBase):
utils.copy_ex(os.path.join(env.root_path, 'out', 'pysrt'), bin_path, (ctx.dist_path, 'pysrt'))
# copy scripts
utils.copy_ex(os.path.join(self.dist_path), self.path_tmp, 'setup.sh')
utils.copy_ex(os.path.join(self.dist_path), self.path_tmp, 'script')
utils.copy_ex(os.path.join(self.dist_path), self.path_tmp, 'daemon')
utils.copy_ex(self.dist_path, self.path_tmp, 'setup.sh')
utils.copy_ex(self.dist_path, self.path_tmp, 'script')
utils.copy_ex(self.dist_path, self.path_tmp, 'daemon')
if os.path.exists(self._final_file):
utils.remove(self._final_file)
utils.sys_exec('chmod +x {}'.format(os.path.join(self.path_tmp, 'setup.sh')))
utils.make_targz(self.base_tmp, self.name, self._final_file)
# utils.remove(self.base_tmp)

View File

@ -72,7 +72,8 @@ void SshProxy::timer() {
// 检查通道是否已经关闭
it->first->check_channels();
// 检查会话是否已经关闭,如果会话已经完全关闭,则销毁之
if (it->first->closed()) {
if (it->first->all_channel_closed()) {
it->first->stop();
delete it->first;
m_sessions.erase(it++);
}

View File

@ -73,6 +73,7 @@ void SshSession::_on_stop() {
if (m_conn_info) {
g_ssh_env.free_connect_info(m_conn_info);
m_conn_info = nullptr;
}
}
@ -158,7 +159,8 @@ void SshSession::check_channels() {
if (m_pairs.empty()) {
EXLOGV("[%s] all channels closed, should close and destroy this session.\n", m_dbg_name.c_str());
m_fault = true;
// m_fault = true;
m_state = SSH_SESSION_STATE_NO_CHANNEL;
}
}
@ -253,7 +255,7 @@ void SshSession::_thread_loop() {
continue;
if (err == SSH_ERROR) {
EXLOGE("[%s] event poll failed. [cli] %s. [srv] %s\n", m_dbg_name.c_str(), ssh_get_error(m_rs_tp2cli), ssh_get_error(m_rs_tp2srv));
EXLOGW("[%s] event poll failed. [client: %s] [server: %s]\n", m_dbg_name.c_str(), ssh_get_error(m_rs_tp2cli), ssh_get_error(m_rs_tp2srv));
m_fault = true;
}
} while (!m_pairs.empty());
@ -265,7 +267,7 @@ void SshSession::_thread_loop() {
ssh_event_remove_session(event_loop, m_rs_tp2srv);
ssh_event_free(event_loop);
m_state = SSH_SESSION_STATE_CLOSED;
// m_state = SSH_SESSION_STATE_CLOSED;
EXLOGV("[%s] session event loop end.\n", m_dbg_name.c_str());
}
@ -449,12 +451,6 @@ int SshSession::_do_auth(const char* user, const char* secret) {
m_conn_info->acc_secret = "*******";
// m_conn_info->acc_username = "INTERACTIVE_USER";
// m_conn_info->acc_secret = "";
// m_conn_info->host_ip = "47.99.60.237";
// m_conn_info->conn_ip = "47.99.60.237";
// m_conn_info->conn_port = 40022;
// m_conn_info->acc_username = "trops";
// m_conn_info->acc_secret = "******";
}
else {
m_conn_info->host_ip = "127.0.0.1";

View File

@ -21,7 +21,7 @@
#define TS_SSH_CHANNEL_TYPE_SFTP 2
enum SSH_SESSION_STATUS {
SSH_SESSION_STATE_CLOSED = 0,
SSH_SESSION_STATE_NO_CHANNEL = 0,
SSH_SESSION_STATE_STARTING,
SSH_SESSION_STATE_AUTHING,
SSH_SESSION_STATE_AUTH_END,
@ -64,8 +64,8 @@ public:
void keep_alive();
bool closed() const {
return m_state == SSH_SESSION_STATE_CLOSED;
bool all_channel_closed() const {
return m_state == SSH_SESSION_STATE_NO_CHANNEL;
}
ssh_session get_peer_raw_session(ssh_session session) {