Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KcpSession io_task_handle loop 不结束 #33

Open
Jaredjin opened this issue Aug 8, 2023 · 3 comments
Open

KcpSession io_task_handle loop 不结束 #33

Jaredjin opened this issue Aug 8, 2023 · 3 comments

Comments

@Jaredjin
Copy link

Jaredjin commented Aug 8, 2023

server模式下, 循环不结束,是否应该添加 input_rx.recv() 失败时结束循环?

let io_task_handle = {
let session = session.clone();
tokio::spawn(async move {
let mut input_buffer = [0u8; 65536];

            loop {
                tokio::select! {
                    recv_result = udp_socket.recv(&mut input_buffer), if is_client => {
                        ...
                    }

                    // bytes received from listener socket
                    input_opt = input_rx.recv() => {
                        ...
                        } else {
                            // 这里结束循环???
                            break;
                        }
                    }
                }
            }
        })
    };
@zonyitoo
Copy link
Collaborator

zonyitoo commented Aug 8, 2023

这里返回 None 的前提应该是 input_tx 析构,或者调用了 close(),目前的实现应该都不可能,因为 KcpSession 不会析构。

io_task_handle.abort();

KcpSession 退出的条件是这里

@Jhonfunk
Copy link

Jhonfunk commented Nov 9, 2023

@zonyitoo

意思是长时间运行会有大量KcpSession泄漏吗

@Matrix-Zhang
Copy link
Owner

@zonyitoo

意思是长时间运行会有大量KcpSession泄漏吗

如果 expire设置为了 0,长时间运行,sessions结构确实会越来越大,这是 UDP 特性导致的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants