pull/236/head
Apex Liu 2019-12-05 09:36:59 +08:00
parent a43f7b0f35
commit 7b0cc6f33d
3 changed files with 10 additions and 7 deletions

View File

@ -72,7 +72,7 @@ bool ExThreadBase::stop(void) {
m_need_stop = true; m_need_stop = true;
_on_stop(); _on_stop();
EXLOGV("[thread] wait thread [%s] exit.\n", m_thread_name.c_str()); EXLOGV("[thread] wait thread [%s] exit, thread-handle=0x%08x.\n", m_thread_name.c_str(), m_handle);
#ifdef EX_OS_WIN32 #ifdef EX_OS_WIN32
if (m_handle) { if (m_handle) {

View File

@ -382,6 +382,7 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr
if ((rv = ts_web_rpc_get_conn_info(conn_id, *info)) != TPE_OK) if ((rv = ts_web_rpc_get_conn_info(conn_id, *info)) != TPE_OK)
{ {
_create_json_ret(buf, rv); _create_json_ret(buf, rv);
delete info;
return; return;
} }
@ -392,6 +393,7 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr
ex_astr sid; ex_astr sid;
if (!g_session_mgr.request_session(sid, info)) { if (!g_session_mgr.request_session(sid, info)) {
_create_json_ret(buf, TPE_FAILED); _create_json_ret(buf, TPE_FAILED);
delete info;
return; return;
} }

View File

@ -1,4 +1,4 @@
#include "ts_session.h" #include "ts_session.h"
#include "ts_env.h" #include "ts_env.h"
#include <mbedtls/sha1.h> #include <mbedtls/sha1.h>
@ -13,6 +13,7 @@ TsSessionManager::TsSessionManager() :
TsSessionManager::~TsSessionManager() { TsSessionManager::~TsSessionManager() {
ts_connections::iterator it_conn = m_connections.begin(); ts_connections::iterator it_conn = m_connections.begin();
for (; it_conn != m_connections.end(); ++it_conn) { for (; it_conn != m_connections.end(); ++it_conn) {
EXLOGD("[core] m_connections not clean: %s, %s\n", it_conn->first.c_str(), it_conn->second->acc_username.c_str());
delete it_conn->second; delete it_conn->second;
} }
m_connections.clear(); m_connections.clear();
@ -28,7 +29,7 @@ void TsSessionManager::_thread_loop(void) {
} }
void TsSessionManager::_remove_expired_connect_info(void) { void TsSessionManager::_remove_expired_connect_info(void) {
// 超过15秒未进行连接的connect-info会被移除 // 超过15秒未进行连接的connect-info会被移除
ExThreadSmartLock locker(m_lock); ExThreadSmartLock locker(m_lock);
@ -87,8 +88,8 @@ bool TsSessionManager::free_connect_info(const ex_astr &sid) {
it->second->ref_count--; it->second->ref_count--;
// 对于RDP来说此时不要移除连接信息系统自带RDP客户端在第一次连接时进行协议协商然后马上会断开之后立即重新连接一次第二次连接之前可能会提示证书信息如果用户长时间不操作可能会导致超时 // 对于RDP来说此时不要移除连接信息系统自带RDP客户端在第一次连接时进行协议协商然后马上会断开之后立即重新连接一次第二次连接之前可能会提示证书信息如果用户长时间不操作可能会导致超时
// 因此,我们将其引用计数减低,并更新一下最后访问时间,让定时器来移除它。 // 因此,我们将其引用计数减低,并更新一下最后访问时间,让定时器来移除它。
if (it->second->protocol_type != TP_PROTOCOL_TYPE_RDP) { if (it->second->protocol_type != TP_PROTOCOL_TYPE_RDP) {
if (it->second->ref_count <= 0) { if (it->second->ref_count <= 0) {
EXLOGD("[core] remove connection info, because all connections closed: %s\n", it->first.c_str()); EXLOGD("[core] remove connection info, because all connections closed: %s\n", it->first.c_str());
@ -99,7 +100,7 @@ bool TsSessionManager::free_connect_info(const ex_astr &sid) {
} else { } else {
if (it->second->ref_count == 1) if (it->second->ref_count == 1)
it->second->ref_count = 0; it->second->ref_count = 0;
it->second->ticket_start = ex_get_tick_count() + 45000; // 我们将时间向后移动45秒这样如果没有发生RDP的第二次连接这个连接信息就会在一分钟后被清除。 it->second->ticket_start = ex_get_tick_count() + 45000; // 我们将时间向后移动45秒这样如果没有发生RDP的第二次连接这个连接信息就会在一分钟后被清除。
} }
@ -133,7 +134,7 @@ bool TsSessionManager::request_session(ex_astr &sid, TS_CONNECT_INFO *info) {
sid = _sid; sid = _sid;
if (info->protocol_type == TP_PROTOCOL_TYPE_RDP) { if (info->protocol_type == TP_PROTOCOL_TYPE_RDP) {
info->ref_count = 1; // 因为RDP连接之前可能会有很长时间用于确认是否连接、是否信任证书所以很容易超时我们认为将引用计数+1防止因超时被清除。 info->ref_count = 1; // 因为RDP连接之前可能会有很长时间用于确认是否连接、是否信任证书所以很容易超时我们认为将引用计数+1防止因超时被清除。
char szTmp[8] = {0}; char szTmp[8] = {0};
snprintf(szTmp, 8, "%02X", (unsigned char) (info->acc_username.length() + info->acc_secret.length())); snprintf(szTmp, 8, "%02X", (unsigned char) (info->acc_username.length() + info->acc_secret.length()));
sid += szTmp; sid += szTmp;