Fix: make UDP and KCP clients stay online
Plain UDP gave every datagram a fresh context and destroyed it after parsing, while the heartbeat handler posted that pointer to the UI thread, so UpdateActiveWindow read freed memory. Login also stored that short-lived context, so later heartbeats carried a zero client id and every UDP host timed out. The UDP server now owns one persistent context per client address and dispatches every datagram through it: the receive buffer is cleared per packet, the map is capped and idle addresses evicted, and Disconnect only erases and marks the context so the last reference deletes it. COMMAND_BYE no longer closes the shared receive socket, a failed receive re-posts itself, and UDP previews are capped to thumbnail size. The KCP client returned ikcp_send's 0 for a successful send, so the caller resent login forever and never started heartbeats; it now reports the accepted length, and a duplicate login re-sends MasterSettings. Two follow-up fixes in the same area: ReleaseIoRef keeps fetch_sub paired with exchange so a concurrent Disconnect cannot strand a marked context at zero refs; UpdateUserEvent drops posted heartbeats while closing instead of touching a context the UDP server may have destroyed. TCP behavior is otherwise unchanged. Verified: Debug build, UDP previews and heartbeats work, KCP logs in once and reports its active window. Server link hits the known LNK1104 from the running exe. Co-Authored-By: Tencent Hunyuan Hy
This commit is contained in:
1 parent
d48f236385
commit
914553ab4e
8 files changed
+280
-30
No files matched your search
@@ -68,7 +68,11 @@ CHideScreenSpyDlg::CHideScreenSpyDlg(CWnd* pParent, Server* pIOCPServer, ClientC
|
||||
CHideScreenSpyDlg::~CHideScreenSpyDlg()
|
||||
{
|
||||
m_bIsClosed = TRUE;
|
||||
m_ContextObject->GetServer()->Disconnect(m_ContextObject);
|
||||
// UDP 主连接上下文归 UDP 服务端的地址映射所有,这里断开会把在线客户端
|
||||
// 从映射里摘掉(宿主列表留下悬空项)。只有子连接(TCP)才需要这里断开。
|
||||
if (m_ContextObject->GetProtocol() != "UDP") {
|
||||
m_ContextObject->GetServer()->Disconnect(m_ContextObject);
|
||||
}
|
||||
DestroyIcon(m_hIcon);
|
||||
Sleep(200);
|
||||
|
||||
|
||||
Reference in new issue
Block a user